system

du

Estimates disk usage of files and directories. Great for hunting the source of a full filesystem.

du [OPTION]... [FILE]...

Common flags

Flag Purpose
-h Human-readable sizes
-s Summarize each argument, no per-file breakdown
-a Include files as well as directories
-c Print a grand total at the end
-d Limit recursion depth (e.g. -d 1)
--max-depth GNU long form of -d
-x Stay on one filesystem

Examples

du -sh /var/log

Summarize the size of one directory

du -h -d 1 /home | sort -h

Rank first-level directories by size

du -shc *.iso

Total the size of matching files

du -ah . | sort -h | tail

Find the largest files under the current directory

Gotcha

du reports allocated blocks, not logical file sizes, so results may exceed the sum of file sizes on sparse files or filesystems with large block sizes.

Related commands

← All Linux commands · Linux cheat sheet