Package Management (Apt/Dnf/Pacman Internals)
Stop letting abandoned config files bloat your /etc directory
đź§© The Challenge
Ever notice how /etc starts feeling like a hoarder’s basement after a few years of upgrades? You uninstall a package, but the configuration files stick around forever, making it impossible to remember what you actually configured and what’s just dead weight.
đź’ˇ The Fix
Use your package manager to hunt down those “conffiles” that got left behind during removals. It’s the easiest way to tidy up without breaking your current services.
dpkg-query -W -f='${Conffiles}\n' | awk '{print $2}' | while read f; do [ -f "$f" ] || echo "$f"; done | xargs -r rm -f
⚙️ Why It Works
This script iterates through every file registered as a configuration file in the dpkg database and checks if the corresponding package is still installed. If the file exists on disk but no longer belongs to any installed package, it’s safe to consider it cruft.
🚀 Pro-Tip: Run this with a dry-run echo first if you have custom scripts living in /etc that aren’t managed by a package.
Linux Tips & Tricks | © ngelinux.com | 10/1/2026
