du – estimate file space usage

du shows disk usage for files and directories. Use it to find what’s consuming space.
Synopsis
du [OPTIONS] [FILE...]
Common Options
| Option | Description |
|---|---|
-h | Human-readable sizes |
-s | Summary only (total for each argument) |
-c | Show grand total |
-a | Show all files, not just directories |
-d N | Max depth of N levels |
--max-depth=N | Same as -d |
-x | Stay on one filesystem |
Examples
Directory size (human-readable)
$ du -sh /var/log
2.4G /var/log
Multiple directories
$ du -sh /home/*
15G /home/greys
8.2G /home/admin
234M /home/guest
All subdirectories
$ du -h /var/log
4.0K /var/log/apt
1.2G /var/log/journal
234M /var/log/nginx
2.4G /var/log
Limit depth
$ du -h --max-depth=1 /var
512M /var/cache
2.4G /var/log
4.0G /var/lib
8.1G /var
Sort by size (largest first)
$ du -sh /var/* | sort -rh
4.0G /var/lib
2.4G /var/log
512M /var/cache
Find largest directories
$ du -h /home | sort -rh | head -10
Include files (not just directories)
$ du -ah /etc | sort -rh | head -20
Show grand total
$ du -shc /var/log /var/cache
2.4G /var/log
512M /var/cache
2.9G total
Stay on one filesystem
$ du -shx / # Won't cross into mounted drives
Common Patterns
Find what’s using space
$ du -h --max-depth=1 / 2>/dev/null | sort -rh | head -15
Top 10 largest directories in /home
$ du -sh /home/*/* 2>/dev/null | sort -rh | head -10
Exclude pattern
$ du -sh --exclude='*.log' /var
Tips
- Always use -h: Human-readable is essential
- Use ncdu: Interactive disk usage browser (better for exploration)
- Combine with sort:
du -sh * | sort -rh - Permission errors: Add
2>/dev/nullto hide them - Different from ls -l: du shows actual disk usage, ls shows file size
See Also
Related Commands
- df — Filesystem space usage
- ls — File sizes with
-lh - ncdu — Interactive disk usage viewer
- find — Find large files






