أهم النقاط
- df shows how full each disk is; du shows what's using the space.
- Logs, old backups and package caches are the usual space hogs.
- A full disk can break databases and stop websites loading.
How full is the disk?
df -h
Look at the Use% column for /. Over 90% needs attention.
What’s using the space?
sudo du -h --max-depth=1 / 2>/dev/null | sort -h
sudo du -h --max-depth=1 /var | sort -h
For an interactive view, install ncdu:
sudo apt install ncdu
sudo ncdu /
Find large files
sudo find / -xdev -type f -size +200M -exec ls -lh {} \; 2>/dev/null
Safe clean-ups
sudo apt autoremove --purge # unused packages
sudo apt clean # package cache
sudo journalctl --vacuum-size=200M
docker system prune # if you use Docker (review what it removes)
Move old backups off the server to separate storage rather than keeping them on the same disk.
الأسئلة الشائعة
The disk is full but du doesn't add up. Why?
A deleted file can still be held open by a running process. Find it with sudo lsof +L1 and restart that service.
Is it safe to delete files in /var/log?
Delete rotated, compressed logs (.gz, .1) freely. For active logs, truncate them or vacuum the journal rather than deleting the file.