How to find large files and free up disk space on a Linux server
This guide shows you how to find large files and free disk space on Linux when your VPS or dedicated server is full. A full disk can stop email, break databases and take websites offline, so it is worth checking quickly and safely.
rm is permanent. Never delete system folders, database files in /var/lib/mysql, or anything you do not recognise. When in doubt, move the file to a backup location or ask support first.Step 1: See which partition is full
df -h
df -i
Note which mount point (/, /home, /backup) is near 100%. If df -i shows 100% inodes, the problem is too many small files, not big ones.
Step 2: Find the biggest folders
du -xh --max-depth=1 / 2>/dev/null | sort -h | tail -n 15
This lists the biggest top-level folders on that partition. Run it again on the largest one, for example /home or /var, to drill down.
For an easier interactive view, use ncdu (from EPEL):
dnf install -y epel-release
dnf install -y ncdu
ncdu -x /
Use the arrow keys to browse. ncdu can delete with d, so be careful.
Step 3: Find individual large files
find / -xdev -type f -size +500M -exec ls -lh {} \; 2>/dev/null
This lists files larger than 500 MB. Change the size to +100M for a wider search.
Usual suspects on a cPanel server
| What | Where | What to do |
|---|---|---|
| Old account backups | /backup, /home/*/backup-*.tar.gz | Lower retention in WHM > Backup Configuration; move old ones off the server |
| Migration files | /home/cpmove-* | Delete after a successful transfer |
| Huge PHP error logs | error_log files in site folders | Fix the error, then empty the file |
| System logs and journal | /var/log | journalctl --vacuum-size=200M |
| Package cache | /var/cache/dnf | dnf clean all |
| Full mailboxes and trash | /home/*/mail | Ask users to empty Trash/Spam or set quotas |
| Plugin backups and cache | wp-content backup and cache folders | Keep backups off the server, clear old cache |
To empty a log file safely without deleting it (the service keeps writing to it):
truncate -s 0 /home/user/public_html/error_log
Step 4: Space not freed after deleting?
If a running process still has a deleted file open, the space is not released. Find such files with:
lsof +L1 2>/dev/null | head
Restart the service that holds them (for example the web server), and the space comes back.
Prevent it next time
- Set disk quotas on every cPanel account through packages.
- Keep backups on remote storage, not on the same disk (see How to configure WHM backups to remote storage).
- Watch disk alerts in WHM and check usage weekly (see How to check server resource usage).
Frequently asked questions
Can I delete files in /tmp?
Old files there are usually safe to delete, but running services may be using recent ones. Avoid deleting while a backup or update runs.
Can I add more disk space instead?
Yes. Contact EgWeb support about upgrading your VPS storage or adding a disk.