« Back to Cheat sheets

du cheat sheet

This article is under development, so might change a few times in a short period. Got feedback or ideas to extend it? Let's improve it together!

Basic options

Long optionShort optionWhat the option does
--human-readable-hShow size in human readable format, such as kilobytes and megabytes
--max-depth=NUMBER-dSet a maximum depth to summary, useful to see size of a particular directory
--summarize-sDon’t show all files or directories, but summarize the output
--threshold=-VAL-tFiles smaller than VAL
--timeShow the last modification time of any file or a sub directory in the specified directory

Creating a shell script? Then we suggest using the long format option, as this improves the readability. For quick use of on the command-line consider using the short notation of the related option.

Show size for a single directory

By setting a max-depth of zero, we can see the size of a particular directory.

du --human-readable --max-depth=0 /var

An alternative is using the --summarize

Relevant articles using du command

The following articles include an example on how to use du and might be worth further exploring.

Liked this cheat sheet? There are more!

Feedback

Small picture of Michael Boelen

This article has been written by our Linux security expert Michael Boelen. With focus on creating high-quality articles and relevant examples, he wants to improve the field of Linux security. No more web full of copy-pasted blog posts.

Discovered outdated information or have a question? Share your thoughts. Thanks for your contribution!

Mastodon icon