- Need to find out the disk usage summary of a directory? Run the following command –
In the output, the first column is the disk usage amount and the second column is the list of files present in that directory.
The first column shows the number of disk blocks the corresponding file is occupying.
- Need the output in a format that human can understand? Use the “-h” option. It tells the “du” to show output in “Human Readable Format”.
- Use “-a” flag for displaying the disk usage of all the files and directories.
As you’ve noticed, you can use multiple flags together with “du”.
- For identifying just how much disk space is a directory consuming, use “-s” flag.
- You can also use the “-c” flag for getting the total size of the directory at the last line of the output.
- Need to check out the last time of file modification? You have to use “–time” flag.
- Are you interested in excluding specific file types, for example, MP4 or PDF? Then use the “–exclude=PATTERN” parameter.
More “du” commands
“du” offers a huge collection of features. You can find out all of them using the man page for “du”.
Every time you need help, you don’t have to open up a terminal and run the command again. You can dump the guide into a text file. Run the following command –