Skip to main content
Version: 1.5.2

how-to-free-up-disk-space-on-linux

How To Free Up Disk Spaceโ€‹

Low disk space can affect server stability and performance. This guide helps you identify and free up disk space on your OpenPanel server.


1. Check Disk Usageโ€‹

Start by checking how much space is currently used:

df -h

To find large directories:

du -h / | sort -hr | head -n 20

2. Clean Up Dockerโ€‹

Docker can quickly consume space with unused containers, images, volumes, and networks.

  • To rrmove unused Docker data:
docker system prune
  • To also remove unused volumes (use with caution):
docker system prune --volumes

๐Ÿงผ Note: This only removes resources not actively in use. Review the list before confirming.

  • View what's taking space:
docker system df

3. Clear Logsโ€‹

Log files often grow large over time:

  • Delete rotated/compressed logs:
rm -f /var/log/*.gz /var/log/*.1
  • Truncate current logs:
truncate -s 0 /var/log/syslog
truncate -s 0 /var/log/auth.log

4. Remove Unused Packagesโ€‹

Free space by removing orphaned packages:

  • For Debian/Ubuntu:
apt autoremove
apt clean
  • For CentOS/RHEL:
yum autoremove
yum clean all

5. Clear Cacheโ€‹

Remove stored .deb or .rpm files:

  • APT cache:
rm -rf /var/cache/apt/archives/*
  • YUM cache:
rm -rf /var/cache/yum

6. Delete Temporary Filesโ€‹

Clean up temp directories:

rm -rf /tmp/*
rm -rf /var/tmp/*

7. Clean User Trashโ€‹

For all users:

rm -rf /home/*/.cache/*
rm -rf /home/*/.local/share/Trash/*

8. Remove Old Backupsโ€‹

Search for old or backup files:

find / -type f \( -name "*.bak" -o -name "*.old" \)

Inspect before deleting.


9. Analyze with ncduโ€‹

Use ncdu for a navigable summary:

apt install ncdu      # Debian/Ubuntu
yum install ncdu # CentOS/RHEL

ncdu /

10. Update OpenPanel (Optional)โ€‹

Updsting OpenPanel removes previous docker images

opencli update --force

Tip: Enable disk usage alerts via OpenAdmin > Settings > Notifications.

Was this helpful?