Skip to content

Disk space recovery on cPanel — du, sort, find

A senior operator's walkthrough of finding where the GB went on a cPanel server with du, sort, and find, and what to clean up safely.

Server is at 92% on /home. Twelve hundred accounts, none individually huge. The question is where the bytes actually went, and the answer rarely shows up in the WHM dashboard. The shortest path is du, sort, and a few find invocations.

What’s happening

cPanel servers accumulate disk usage in predictable but distributed places: customer mail folders that grew without quota, error logs that nobody rotated, untrimmed Apache access logs, backup archives left by previous operators, stranded session files. Each individually is small; together they can be 20% of the disk.

How to verify

Top-down scan, biggest first:

df -h /home
du -sh /home/* 2>/dev/null | sort -h | tail -20
du -sh /var/log 2>/dev/null
du -sh /usr/local/cpanel/logs 2>/dev/null
du -sh /backup 2>/dev/null
find / -type f -size +500M 2>/dev/null

The du -sh /home/* | sort -h | tail gives you the top 20 accounts by size. The single-file find catches huge log files and stray .tar archives that don’t belong to any cPanel account.

The fix

  1. Investigate the top 5 accounts. For each: du -sh /home/<user>/* | sort -h | tail. The pattern is usually mail (biggest), then public_html (varies), then .trash or .cpanel.
  2. Mail audit: du -sh /home/<user>/mail/* | sort -h | tail. Mailboxes over 5 GB often have unfetched spam-quarantine accumulations. Coordinate with the customer before pruning.
  3. Logs: find /var/log /usr/local/cpanel/logs -size +100M. Rotate or compress, but don’t blindly delete — some logs are still tailed by monitoring.
  4. Backups: find /backup -type d -mtime +30. Old cpmove-*.tar.gz archives in /backup from manual migrations are pure waste once the migration is done.
  5. Per-account cache and trash: du -sh /home/<user>/{.cpanel,.trash,tmp}. Each can be safely cleared (see the dedicated KB articles for the specific paths).
  6. After cleanup, run du -sh /home and confirm the recovery matches expectations. Run df -h immediately after — file systems sometimes lag in updating free-space accounting.

Stack Harbor runs disk-space audits as part of regular operations under cPanel server management.