10 Useful du (Disk Usage) Commands to Find Disk Usage of Files and Directories

The Linux “du” (Disk Usage) is a standard Unix/Linux command, used to check the information of disk usage of files and directories on a machine. The du command has many parameter options that can be used to get the results in many formats. The du command also displays the files and directory sizes in a recursively manner.

10 Useful du Commands

This article explains 10 useful “du” commands with their examples, that might helps you to find out the sizes of files and directories in Linux. The information provided in this article are taken from the man pages of ducommand.

Read Also:

  1. 12 “df” Command to Check Linux System Disk Space

1. To find out the disk usage summary of a /home/tecmint directory tree and each of its sub directories. Enter the command as:

The output of the above command displays the number of disk blocks in the /home/tecmint directory along with its sub-directories.

2. Using “-h” option with “du” command provides results in “Human Readable Format“. Means you can see sizes in BytesKilobytes, MegabytesGigabytes etc.

3. To get the summary of a grand total disk usage size of an directory use the option “-s” as follows.

4. Using “-a” flag with “du” command displays the disk usage of all the files and directories.

5. Using “-a” flag along with “-h” displays disk usage of all files and folders in human readeable format. The below output is more easy to understand as it shows the files in KilobytesMegabytes etc.

6. Find out the disk usage of a directory tree with its subtress in Kilobyte blcoks. Use the “-k” (displays size in 1024 bytes units).

7. To get the summary of disk usage of directory tree along with its subtrees in Megabytes (MB) only. Use the option “-mh” as follows. The “-m” flag counts the blocks in MB units and “-h” stands for human readable format.

8. The “-c” flag provides a grand total usage disk space at the last line. If your directory taken 674MB space, then the last last two line of the output would be.

9. The below command calculates and displays the disk usage of all files and directories, but excludes the files that matches given pattern. The below command excludes the “.txt” files while calculating the total size of diretory. So, this way you can exclude any file formats by using flag “-–exclude“. See the output there is no txtfiles entry.

10. Display the disk usage based on modification of time, use the flag “–time” as shown below.

Read Also :

  1. 10 fdisk Commands to Manage Linux Disk Partitions
  2. 12 Useful “df” Commands to Check Disk Space in Linux

Leave a Reply