📘Free up Disk Space on a cPanel Server (2025)

Over time, a cPanel server can accumulate log files, backups, and temporary data that eat up disk space. Use the commands below to safely remove unnecessary files and reclaim storage across /home, /usr, and /var.

⚠️ Important: Always ensure you have recent backups before deleting files.


🧹 Clear /home Directory

Remove common clutter from user directories and cPanel operations.

# Delete all error_log files inside /home
find /home -type f -name error_log -delete

# Remove EasyApache build directory
rm -rfv /home/cpeasyapache

# Delete Softaculous backups
rm -fv /home*/*/.softaculous/backups/*
rm -rfv /home/*/softaculous_backups

# Remove user backup archives
for user in `/bin/ls -A /var/cpanel/users` ; do rm -fv /home/$user/backup-*$user.tar.gz ; done

# Remove Fantastico backups
rm -rfv /home/*/fantastico_backups

# Remove temporary cPanel files
rm -fv /home/*/tmp/Cpanel_*

# Delete leftover cPanel transfer and restore files
rm -rvf /home/cpmove-*
rm -rvf /home*/cpanelpkgrestore.TMP*

🧹 Clear /usr Directory

Free up space in system and application directories.

# Remove old Apache backup directories
rm -rfv /usr/local/apache.backup*

# Remove old Maldet backup folders and logs
rm -rfv /usr/local/maldet.bk*
rm -fv /usr/local/maldetect/logs/*

# Clean old compressed log archives
rm -fv /usr/local/cpanel/logs/archive/*.gz
rm -fv /usr/local/apache/logs/*.gz
rm -fv /usr/local/apache/logs/archive/*.gz

🧹 Reduce /var Usage

Clear archived and old log files:

# Delete gzipped and date-stamped logs
rm -fv /var/log/*.gz
rm -fv /var/log/*201*

🔍 Find Large Files and Directories

Identify large directories or files for manual inspection:

# Example for checking MySQL data usage
cd /var/lib/mysql
du --max-depth=1 | sort -n | awk 'BEGIN {OFMT = "%.0f"} {print $1/1024,"MB", $2}'

Replace /var/lib/mysql with any path you want to analyze.


✅ Final Notes

  • Consider scheduling log rotation and cleanup with logrotate.
  • Avoid deleting files if you’re unsure of their use—check modification dates with ls -lhtr or stat.

Keep your server clean and efficient with regular maintenance!

Scroll to Top