Package Management (Apt/Dnf/Pacman Internals)
Hunting down orphan config files left behind by removed packages
đź§© The Challenge
Ever notice how your /etc folder turns into a graveyard of dead config files after you remove a bunch of old packages? It drives me nuts knowing that junk is sitting there when I’m trying to keep a clean server.
đź’ˇ The Fix
Use dpkg to filter for files that are in the config-files state rather than fully installed. It clears out the clutter that apt-get remove leaves behind by design.
dpkg-query -W -f='${db:Status-Status} ${Package}\n' | grep '^config-files$' | cut -d' ' -f2 | xargs -r sudo apt-get purge
⚙️ Why It Works
The package database keeps these entries marked as config-files so you can recover your settings if you reinstall the package later, but most of the time it’s just garbage you don’t need. Running this purge cleans the actual files from the disk and removes them from the package registry for good.
🚀 Pro-Tip: Run this after a massive spring cleaning of your server’s service list to keep your config backups sane.
Linux Tips & Tricks | © ngelinux.com | 7/13/2026
