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.
Here, we will discuss about the 7 useful du commands
1. To find out the disk usage summary of a /home/directoryname directory tree and each of its sub directories. Enter the command as:
du /home/directoryname
2. Using “-h” option with “du” command provides results in “Human Readable Format“. Means you can see sizes in Bytes, Kilobytes, Megabytes, Gigabytes etc.
du -h /directoryname
3. To get the summary of a grand total disk usage size of an directory use the option “-s” as follows.
du -sh /directoryname
4. Using “-a” flag with “du” command displays the disk usage of all the files and directories.
du -a /directoryname
5. Using “-a” flag along with “-h” displays disk usage of all files and folders in human readeable format.
du -ah /directoryname
6. To get the summary of disk usage of directory tree along with its subtrees in Megabytes (MB) only by using this option “-mh”
du -mh /directoryname
7. The “-c” flag provides a grand total usage disk space at the last line
du -c /directoryname
We hope you’ve found this useful!