du - estimate file space usage
du [-h] [-s] [-x] [--max-depth=N] [path]
Options you will use
-h, --human-readable- Print sizes in K, M, G.
-s, --summarize- One total per argument.
-x, --one-file-system- Skip directories on other filesystems. Essential when starting at /.
--max-depth=N- Only report totals down to N levels.
-a- Report for files as well as directories.
--apparent-size- Print the file size (bytes in it) instead of the disk space used.
--inodes- Count inodes (files) instead of space.
-k- Sizes in kilobytes (1024 bytes).
Examples
$ sudo du -xh / --max-depth=2 2>/dev/null | sort -h | tail -10top 10 biggest directories, staying on one filesystem
Gotchas
- du walks the tree and adds up what it can SEE. df asks the filesystem. They disagree when a deleted file is still open, or when du cannot read a directory.
Taught in
Try du in a real terminal Free, in your browser - a real Ubuntu terminal to try it in, with missions that check your work.