/ Linux

Purge Old Package Configuration


Here is a simple command for completely removing old uninstalled packages from your Debian based distribution and their configuration files:

# Purges removed packages with tracked files.
dpkg -l | egrep '^rc.*' | awk '{ print $2 }' | tr '\n' ' ' | xargs sudo apt purge

The problem with apt[-get] remove is that it will uninstall the program but it will not remove old configuration files. That is what the purge command is for. If you execute dpkg -l you sometimes find that there are many old packages being tracked as they still have configuration files left over. These packages will display rc instead of ii in the first column as they have been removed from the system but files still remain on your system. The command above will completely remove these files leaving your system slimmer and feeling fresh. Make sure to verify that you are not using any of the configuration files from the packages before purging.