When VPS Storage Starts “Crying for Help”
You wake up to a red alert: your VPS disk usage has hit 95%. This is extremely common if you’ve been running Ubuntu for 3-6 months without maintenance. Cleaning Linux isn’t just about deleting temp files. The real “space hogs” are usually redundant dependencies, old Kernels, and GBs of silently accumulating logs.
Based on my experience managing over 20 VPS clusters, I’ve distilled a cleanup process that reclaims between 2GB and 10GB of space in just minutes. This doesn’t just free up memory; it also helps prevent silly system conflicts when upgrading software later.
Why Does Ubuntu Storage Keep “Bloating” Over Time?
Orphaned Packages
Imagine you install Nginx; the system pulls in 10 supporting libraries. When you remove Nginx, Ubuntu often leaves those 10 libraries behind, fearing other software might need them. The result is a system riddled with unused remnants.
Old Kernel Collection
Every time the kernel is updated, Ubuntu keeps the old version as a fallback in case of boot issues. However, each Kernel and its associated files take up about 300MB – 500MB. If you let 5-7 versions accumulate, you’re wasting several GBs.
Residual Configuration Files
The standard apt remove command only deletes executables while keeping configurations in /etc. If you don’t plan to use that software again, these files just clutter the system and bloat boot entries.
Steps for a Thorough System Cleanup
1. Optimize the APT Package Manager
Don’t just use basic autoremove. Add the --purge flag to wipe out junk configuration files attached to dependencies.
sudo apt update
sudo apt autoremove --purge -y
sudo apt autoclean
- autoremove –purge: Wipes out libraries no longer used by any program.
- autoclean: Cleans the local repository of outdated installation files (.deb).
2. Scan for Orphaned Packages with Specialized Tools
Sometimes APT still misses libraries it thinks “might be needed.” deborphan helps you identify these strays more accurately.
Installation and quick execution:
sudo apt install deborphan -y
sudo apt purge $(deborphan) -y
Pro tip: You should run this command 2-3 times. After removing one layer of orphaned packages, their own dependencies often become orphans in the next layer.
3. Clear Residual Configuration States (rc status)
When listing packages with dpkg, you’ll see many with an rc status—meaning they are removed but have leftover configuration files. Use this command to clean them all at once:
dpkg -l | grep '^rc' | awk '{print $2}' | xargs sudo dpkg --purge
This command filters the list, gets the package names, and performs a thorough purge. It’s the fastest way to clean the /etc directory.
4. Safely Manage Old Kernels
First, check the Kernel version you are currently running to avoid accidental deletion:
uname -r
Newer Ubuntu versions (20.04+) have become smarter at self-cleaning via autoremove. However, if you want to manually delete a specific version taking up space, use:
sudo apt purge linux-image-5.x.x-generic -y
Note: Always keep at least one stable old Kernel as a backup in case the latest version has boot issues.
5. Limiting Systemd Log’s “Thirst” for Space
Journald (system log) can consume up to 10% of your disk or default to 4GB. This is often where the most space can be reclaimed on long-running servers.
Check current log usage:
journalctl --disk-usage
Set logs to be kept for only 3 days or limit the maximum size to 500MB:
sudo journalctl --vacuum-time=3d
sudo journalctl --vacuum-size=500M
6. Cleaning the Snap Cache
If you install software via Snap, it stores at least two old versions of every app. Run this script to remove disabled versions:
set -eu
snap list --all | awk '/disabled/{print $1, $3}' |
while read snapname revision; do
snap remove "$snapname" --revision="$revision"
done
Conclusion
Cleaning Ubuntu should be a monthly habit. If you’re too busy, set up a cronjob to automatically run basic log and APT cleanup commands. Maintaining a clean system not only saves you VPS storage upgrade costs but also keeps the server responsive.
Now, try typing df -h and see how many GBs you’ve reclaimed. Happy sysadmin-ing!

