Can I get the list of the packages whose configuration is needed to be purged?

I Tried to get the list of all the removed packages whose configurations are to be purged through this command dpkg -l but there was a very huge list. Is there any command to get the list of all the packages which are needed to be purged?


Solution 1:

You will be missing the header row, but the command

dpkg-query -l | awk '/^.c/'

will list the packages in which only config files exist


The list of packages found by awk could be deleted with a change to the program

dpkg-query -l | awk  '/^.c/ { system("sudo dpkg --purge " $2) }'

It should be noted that I don't think this is a great idea: I think it would be preferable to list the output from the search to a file, verify that you are ok with removing the packages named, and then use the text file as an input to dpkg:

dpkg-query -l | awk  '/^.c/' > ~/DpgkTargets
sudo nano ~/DpkgTargets
sudo dpkg --purge < ~/DpkgTargets