Situatie
When a Linux server or PC runs out of space, you need to find the largest folders and files quickly.
Requirements: terminal access with sudo privileges.
Solutie
- Check overall usage per filesystem:
df -h
- List the biggest top-level folders (the
-xoption stays on one filesystem):
sudo du -xh / --max-depth=1 2>/dev/null | sort -hr | head -15
- Go deeper into the largest folder, for example
/var:
sudo du -xh /var --max-depth=1 2>/dev/null | sort -hr | head -15
- Find individual files larger than 500 MB:
sudo find / -xdev -type f -size +500M -exec ls -lh {} + 2>/dev/null
- For an interactive view, install and run
ncdu:
sudo apt install ncdu
sudo ncdu -x /
Use the arrow keys to navigate, press d to delete the selected item (after confirmation) and q to quit.
- Clean common space hogs on Debian/Ubuntu:
sudo apt clean
sudo journalctl --vacuum-size=200M
- Run
df -hagain to confirm the space was recovered.
Warning: never delete files from /etc, /usr or /boot unless you know exactly what they are.
Leave A Comment?