Disk Space: du and df
What is using my disk?.
Sooner or later, a disk fills up. When that happens, you need two answers. How much space is left? And what's using it all? DF and DU answer those questions.

- The disk is full
- How much is left?
- What's using it?
How much space is left
DF, for disk free, shows each disk, its size, how much is used, and how much is available. Dash H makes the numbers human readable, in gigabytes. We pass slash, so we only see the main disk. On your computer, the name and the numbers will be different, but the columns are the same.
df -h / Filesystem Size Used Avail Use% Mounted on overlay 103G 40G 58G 41% /
What is using the space
DU, for disk usage, shows how much space files and folders take. Dash SH gives one human readable total for each name. Downloads is the biggest, at about three point three megabytes. Now we know where to start cleaning.
du -sh * 12K Documents 3.3M Downloads 8.0K Music 60K Pictures 4.0K notes.txt 12K projects 4.0K todo.txt du -sh Downloads 3.3M Downloads
Finding the biggest folders
A popular combination sorts the folders by size, so the biggest come last. DU dash SH star, then a pipe, into sort dash H. We'll learn sort properly soon. And the find command from before, with dash size, finds the biggest single files.
| key | value |
|---|---|
| df -h | space left on each disk |
| du -sh * | size of each item here |
| du -sh * | sort -h | biggest last |
| find -size +100M | big single files |
Summary
DF dash H shows free space, and DU dash SH shows what's using it. Next, a challenge to practise everything about files.
Key takeaways- df -h
- du -sh *
- sort -h for biggest