← All newsletters

Three ways to look at your disk.

What fills your disk, what to delete first, and why du sees the world differently than df.

Disk-full errors surprise most new Linux users. They shouldn't. Linux shows you where the space went in three different ways, and each answer is correct.

Use df when you want the system view.

df -h shows every mounted filesystem, how full it is, and how much is free. It reports what the kernel thinks: real, authoritative, accurate. Read this when you need to know “am I about to run out of disk?”

Use du when you want the user view.

du -sh /var shows the size of a directory, summed. du -ah ~ | sort -h | tail -20 shows your twenty biggest files. du counts what's in each folder by walking the tree. Read this when you need to know “what is filling my disk?”

Use lsblk when you want the hardware view.

lsblk shows the disks and partitions the system can see. Which drive you're on, which partitions exist, where things are mounted. Read this when you need to know “is this even the right disk?”

When df says you have 12 GB free and du says you only have 4 GB of files, the missing 8 GB is a deleted file the kernel is still holding open. Restart whatever has the handle. Terminally Online #042

The three commands cover ninety percent of disk questions. The other ten percent is “why is /var/log 40 GB” — which is the subject of next Friday's issue.

Subscribe to Terminally Online for the daily edition.