Lesson 13: System resources — df, du, free
The server stopped writing logs. journalctl was silent. You ran df -h — /var at 99% usage. That's 'No space left on device': disk full, no room to write anything. du -sh /var/log revealed the logs had grown to 4.5 GB; after cleanup everything came back. This lesson covers three resource commands: df
df is how much space is left in the closet. du is checking which drawer is the fullest. free is how much memory (RAM) is free to work with.
- df
- 'disk free' — shows disk usage per partition. df -h displays in human-readable format (GB/MB). Use% is the percentage of the partition in use — at 100%, the server gets 'No space left on device' and cannot write anything.
- du
- 'disk usage' — shows how much space a directory takes. du -sh /var/log = summary (-s) in human-readable format (-h) of /var/log. When df shows high Use%, du finds what's 'eating' the disk.
- free
- Shows RAM state: total, used, and available. free -h displays in GB/MB. RAM is different from disk — a large file doesn't fill RAM, it fills disk.
- No space left on device
- Error when the disk is full (Use% = 100%). The server can't write logs, temp files, or anything else. Diagnose with df, find the culprit with du, then clean.