Score:1

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

kp flag

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?

Scott Stensland avatar
ir flag
command `dpkg -l` will list all packages so its a read only command ... notice at the top a header which explains meaning of the far left column of each package row
Score:5
cn flag

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
Vivek Sundaray avatar
kp flag
ok got it. How can I remove all those packages with a single command ?
Charles Green avatar
cn flag
@VivekSundaray The 'system' command in awk could do it: `dpkg-query -l | awk '/^.c/ { system("sudo dpkg --purge " $2) }'` - it should go without saying that this should be used very cautiously. I will expound in the answer
Vivek Sundaray avatar
kp flag
Thanks a lot. I am not going to remove it but just wanted to know
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.