Check Disk Space with df and du
When a disk fills up, programs stop working properly. df shows how much space is free on each disk, and du shows which folders are using it.
Free space on each disk
df -hShows the size, used space and free space of each disk, in easy to read units (G, M).
df -h /homeShows just the disk that holds /home.
What is using the space
du -sh documents/Shows the total size of the documents folder.
du -h --max-depth=1 . | sort -hShows the size of each folder in the current directory, smallest to largest.
du -sh * | sort -h | tailShows the 10 biggest files and folders in the current directory.
sudo du -xh --max-depth=1 / 2>/dev/null | sort -hShows which top-level folders use the most space on the main disk. -x stays on one disk.
Finding big files
find . -type f -size +100MLists files bigger than 100 MB. See the find guide for more.
Tip: ncdu is an interactive tool for exploring disk use. Install it with sudo apt install ncdu, then run ncdu.
Quick reference
| Option | Meaning |
|---|---|
df -h | Free space on each disk |
du -sh folder | Total size of a folder |
du -h --max-depth=1 | Size of each folder, one level down |
sort -h | Sort sizes like 1K, 2M, 3G |
-x | Stay on one disk |