Stop apt from holding onto deleted config files like a packrat
Package Management (Apt/Dnf/Pacman Internals)
Stop apt from holding onto deleted config files like a packrat
🧩 The Challenge
You uninstall a package, but the configuration files stay behind, leaving your /etc directory feeling like a cluttered junk drawer that just grows over time. It’s annoying because these “rc” state files clutter up your grep results and make auditing security settings a total headache.
💡 The Fix
Use the purge flag when removing packages to wipe out those config files entirely, or hunt down the ones left in the “rc” state to clean them out in one go. You’ll thank yourself later when you’re looking for a specific config and don’t have to wade through a graveyard of deleted packages.
dpkg -l | grep '^rc' | awk '{print $2}' | xargs sudo apt-get purge -y
⚙️ Why It Works
This pipeline pulls a list of packages marked with “rc” (removed but config files remain), strips out the package names, and feeds them into the purge command to finally delete them. APT usually keeps these around in case you reinstall the software, but honestly, I rarely need them if I’ve already decided to remove the package.
🚀 Pro-Tip: Alias this command as “purge-cruft” and run it once a month to keep your system clean.
Linux Tips & Tricks | © ngelinux.com | 10/21/2026
