« 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

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

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!


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