💾 Checking Disk Usage (df, du)
Imagine your computer's storage like a giant bookshelf. You need to know how full each shelf is and how much space each book takes. Linux gives us two main commands for this: df and du.
df – Disk Free
Shows overall disk usage of mounted filesystems.
Analogy: Think of df as looking at the entire bookshelf and checking how much space is left on each shelf.
- -h → human-readable (shows sizes in KB, MB, GB instead of blocks)
Filesystem Size Used Avail Use% Mounted on /dev/sda1 50G 20G 28G 42% /
This shows the total, used, and available space for each filesystem.
du – Disk Usage of files/folders
Shows how much space a file or directory is using.
Analogy: If df is checking the whole bookshelf, du is measuring each book individually.
- -h → human-readable
- -s → summary (total size of folder)
2.5G /home/user/Documents
Meaning your personal folder takes 2.5 GB.
💡 Tip
Use df first to see which disk is almost full, then du to find which folders/files are eating up space.
Real-life analogy
Think of your computer's storage like a giant bookshelf:
df is like standing back and seeing how full each shelf is overall.
du is like going shelf by shelf, measuring each book to see which ones are taking up the most space.
You use df to spot a crowded shelf, then du to identify the biggest books that might need to be moved or removed.