Site icon New Generation Enterprise Linux

Stop apt from keeping ghost packages around after a dist-upgrade

Package Management (Apt/Dnf/Pacman Internals)

Stop apt from keeping ghost packages around after a dist-upgrade

🧩 The Challenge

You know that feeling when you run a massive dist-upgrade and your disk space mysteriously stays full? Half the time it’s because apt keeps old kernel headers and deprecated library versions stuffed in the local cache, clogging up the works.

💡 The Fix

Use the autoremove flag combined with purge to kick those unused dependencies to the curb for good. It’s the only way to make sure the config files go with them, instead of leaving clutter behind.

sudo apt-get autoremove --purge

⚙️ Why It Works

This command tells apt to calculate which packages were automatically installed to satisfy dependencies for other packages but are no longer needed, then wipes their configuration files off the disk entirely.

🚀 Pro-Tip: Alias this to something like ‘nuke-junk’ so you stop forgetting to run it after every kernel update.

Linux Tips & Tricks | © ngelinux.com | 8/30/2026

0 0 votes
Article Rating
Exit mobile version