A full disk stops databases, breaks updates and takes websites offline. Three commands tell you everything: df shows how full each filesystem is, du shows how big folders are, and ncdu lets you browse usage interactively.
Before you start
- SSH access to your VPS (see connect with SSH).
- sudo rights, so you can read every folder.
See free space with df
df -hCheck the Use% column for /. Above 90% you should clean up soon; at 100% services start failing. -h prints sizes in G and M. To show only real disks:
df -h -x tmpfs -x devtmpfsCheck inodes too
df -iEvery file uses one inode. Millions of tiny files (cache, session or mail files) can exhaust inodes while space remains, giving "No space left on device" with free gigabytes.
Find big folders with du
sudo du -h --max-depth=1 / 2>/dev/null | sort -hThen drill into the largest one, for example /var:
sudo du -h --max-depth=1 /var | sort -hShow the size of one folder only with du -sh /var/log.
Browse interactively with ncdu
sudo apt install ncdusudo dnf install ncdusudo ncdu -x /Use the arrow keys and Enter to move through folders, sorted by size. -x stays on one filesystem. Pressing d deletes the selected item, so be careful; q quits.
Usual space hogs
| Location | What it is | Safe action |
|---|---|---|
/var/log | Logs and the systemd journal | sudo journalctl --vacuum-size=500M, check logrotate |
/var/cache/apt or /var/cache/dnf | Downloaded packages | sudo apt clean or sudo dnf clean all |
/var/lib/docker | Images and containers | See docker prune |
/home, /backup | Old archives and backups | Move off-server, then delete |
Warning: Deleting a log file that a service still writes to does not free the space until the service restarts. Empty it instead: sudo truncate -s 0 /path/file.log.
Troubleshooting
- df says full, du finds little: a deleted file is still held open. Find it with
sudo lsof +L1and restart that service. - Permission denied lines: run
duwith sudo, or add2>/dev/null.
