Skip to content

How full is the disk? df and du

IntermediateLesson 19 of 666 min

See how full a disk is with df -h, find what takes the space with du -sh and sort -h, then free some. Practise on a nearly full disk in your browser.

"No space left on device" is one of the most common errors on any computer. Two commands answer the two questions you'll have.

df: how full is each disk?

df (disk free) lists each disk with its size, what's used and what's left. -h gives sizes like 1.4M or 512G instead of counting kilobytes:

df -h

The Use% column is the one to watch.

du: what is taking the space?

du (disk usage) adds up how much space folders take, including everything inside them. -s gives one total per name and -h readable sizes:

du -sh downloads
du -sh *

With many folders, sort the list so the biggest comes last. sort -h understands sizes like 12K and 1.5M; plain sort -n would put 900K after 1.5M.

du -sh * | sort -h

Tip:The practice disk is tiny, 2 MB in all, so these files are small. A real disk is thousands of times bigger, and the commands are exactly the same.

Your turn

The disk is filling up. Check how full it is with df -h, find which folder in your home takes the most space with du, delete the three old .iso installers in it (keep everything else), then run df -h again to see the space come back.

Next