The du command

estimate file space usage 9 examples from the lessons of the IVski Linux Playground — try them in the terminal next to them.

Options in the examples

-h, --human-readable
print sizes in human readable format (e.g., 1K 234M 2G)
-s, --summarize
display only a total for each argument
-d, --max-depth=N
print the total for a directory (or file, with --all) only if it is N or fewer levels below the command line argument; --max-depth=0 is…

Examples

du -h

Current directory, human-readable

du -sh

Summary of current directory

du -sh *

Size of each item in current dir

du -sh /var/*

Size of each subdirectory

du -h --max-depth=1 /var

One level deep

du -sh /var/* | sort -rh | head -10
du -sh /var/log/*

Which directories are biggest?

du -sh /* 2>/dev/null | sort -rh | head

Top-level space hogs, sorted

sudo du -sh /var/log/*

Where are the big files…?

Lessons that use du

Related commands