The short answer
Run df -h, then du to find the biggest folder, clean logs, caches and old backups, and check inodes and deleted-but-open files if space does not come back.
How full is it?
df -h
df -idf -h shows space. df -i shows inodes: a disk can be full of tiny files with plenty of space left.
Find the big folders
sudo du -xh / --max-depth=1 2>/dev/null | sort -h | tail -n 12
sudo du -xh /var --max-depth=2 2>/dev/null | sort -h | tail -n 12Go one level deeper into the biggest folder, again and again. Install ncdu for an easier view.
Usual suspects
- Logs in /var/log: rotate or compress them, and set a limit on the journal with
journalctl --vacuum-size=200M. - Backups: on cPanel servers, /backup and /home/*/backup can grow fast.
- Mail queue and spool: a spam problem can fill /var/spool.
- Package caches:
apt cleanordnf clean all. - Docker:
docker system df, thendocker system pruneafter reading what it will delete. - Core dumps and old kernels.
Space does not come back?
sudo lsof +L1 | headA deleted file that a program still holds open keeps using space. Restart that program to release it.
Stop it happening again
- Alert at 80% disk use.
- Set log rotation for every app.
- Keep backups on another system, not on the same disk.
Questions people ask
Is it safe to delete files in /var/log?
Truncate or rotate them instead of deleting: `truncate -s 0 file.log`. Deleting a log a program has open does not free space.
The disk is not full but I get "no space left"?
You may be out of inodes. Check df -i and look for folders with millions of small files, such as session or cache folders.
Should I grow the disk?
If the data is real and growing, yes. If it is junk, clean it first.