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
df
Reports filesystem disk-space usage. Shows total, used, and available space per mounted filesystem.
sort
Sorts lines of text. Supports numeric, human-numeric, reverse, unique, and keyed sorting.
find
Recursively walks directories evaluating expressions on each entry. Combines discovery with actions like exec or delete.
free
Displays free and used memory including RAM and swap. Reads from /proc/meminfo and summarizes at a glance.