Package Management (Apt/Dnf/Pacman Internals)
Stop apt from holding onto those dusty old package caches
🧩 The Challenge
Dealing with a production box that keeps screaming about a full root partition because it’s hoarding gigabytes of old .deb files from three years of updates. You know they are there, yet apt clean never seems to reclaim the space you actually expect.
💡 The Fix
Dig into the actual cache directory directly to see what is hiding in the archives and force a proper purge of the local repository state. It’s the only way to be sure you aren’t carrying dead weight from abandoned versions.
du -sh /var/cache/apt/archives/
find /var/cache/apt/archives/ -type f -name "*.deb" -mtime +30 -delete
apt-get clean
⚙️ Why It Works
By manually targeting the archives directory with find based on modification time, you strip away the debris that apt-get clean sometimes misses if the package metadata has drifted. Running the clean command afterwards just tidies up the lock files and remaining index pointers.
🚀 Pro-Tip: Stick this in a simple monthly cron job if you are tired of playing disk tetris on your smallest cloud instances.
Linux Tips & Tricks | © ngelinux.com | 7/14/2026
