I have spent literally hours over the last year or two searching for an elegant way to remove configuration files left over from package installs, in a command line environment, with Ubuntu.
Googling would provide a frustrating list of solutions that would either involve installing extra packages, using a complicated command line, or script, solutions that I would never be happy with and would “redo” the search again, each time I wanted to perform the same task, in the hope of finding something better.
In the end Aptitude and Xargs were my friends. Without further ado ….
aptitude -F %p search '~c' | sudo xargs dpkg -P
Please note this command is meant for server/cli environments only. Desktop users should use Synaptics and the “Not Installed (residual config)” status. Nanny out.