Skip to content

How to clear disk space on CentOS/RHEL 6, 7, 8?

Updated 2 min read

Updated: 28 September 2026 · Applies to: Ubuntu 24.04, Debian 12, AlmaLinux 9 and Rocky Linux 9

CentOS 6/7/8 are end of life; these steps are for Ubuntu 24.04, Debian 12, AlmaLinux 9 and Rocky Linux 9. Do not run cleanup scripts from the internet that you have not read: find out what uses the space first, then remove only what you understand.

1. Find what uses the space

df -h                                            # which file system is full
du -xh / --max-depth=1 2>/dev/null | sort -h     # biggest top-level folders
find / -xdev -type f -size +500M -exec ls -lh {} \;   # files over 500 MB

ncdu -x / (from EPEL, or apt install ncdu) lets you browse sizes interactively.

2. Safe cleanups

dnf clean all                         # AlmaLinux / Rocky package cache
dnf remove --oldinstallonly           # old kernels (keeps the running one)
apt clean && apt autoremove --purge   # Ubuntu / Debian
journalctl --disk-usage
journalctl --vacuum-size=200M         # shrink the systemd journal

To keep the journal small permanently, set SystemMaxUse=200M in /etc/systemd/journald.conf and restart systemd-journald.

3. Large log files

Empty a log that a program still writes to with truncate -s 0 /var/log/big.log (deleting it does not free the space until the program restarts). Then check that logrotate handles it: see /etc/logrotate.d/.

4. Space not freed after deleting

A running program may still hold the deleted file open. Find it with lsof +L1 and restart that service.

Other common space users

  • Old backups and archives in /root, /home or /backup.
  • Docker images and volumes: check with docker system df.
  • On cPanel accounts, use Files › Disk Usage in cPanel to see which folders are large, and empty old email with the Email Disk Usage tool.

Note: Never delete files in /var/lib/mysql by hand. Drop databases you no longer need from MariaDB/MySQL, or ask our support team.

Related services

KVM VPS hosting

NVMe SSD and full root access, with Free Basic Managed Support.

Unmanaged dedicated servers

full root access and free IPMI KVM, with Free Basic Managed Support.

Linux server management

hardening, patching, monitoring and automation for Ubuntu, Debian, RHEL and AlmaLinux.

Was this answer helpful?

Still stuck? Open a ticket