Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm basically looking for an apt-get purge for programs that are already uninstalled.

(I'm running Debian squeeze and using aptitude for package management.)

share|improve this question

The following sequence will list your deinstalled packages,

dpkg --get-selections | grep deinstall

You can switch that to purge with a sed replace.
Is that what you are looking for?

You can run that purge list through dpkg --set-selections and
run dpkg --purge --pending on the marked packages...

Or, something like,

for pkg in $(dpkg --get-selections | grep deinstall | awk '{print $1}'); 
  dpkg -L $pkg; 

will list the files hanging around from these deinstall'ed packages.

share|improve this answer
Actally, it seems like if you apt-get remove a package that has configuration files, you can later remove them just with apt-get purge $package. IIRC, I'd tried that and it didn't work, through, giving me a package-not-installed error… – Blacklight Shining Jul 13 '12 at 19:00
Hmm. Did you try dpkg -L on these packages? Does it show any files? – nik Jul 13 '12 at 20:11
Just tested this again. Did a dpkg --get-selections | grep deinstall, then picked one of the packages from that output. dpkg -L $package listed several configuration files the package had created. apt-get remove $package returned a not-installed-so-not-removed warning, but apt-get purge $package asked if I wanted to continue with removing the package, then did so. After that, it did not show up in dpkg --get-selections | grep deinstall. – Blacklight Shining Jul 18 '12 at 6:26
Hmm, that is not my experience. When I run purge, it says "Package $package is not installed, so not removed", and then it still shows up in the list. – Trejkaz Oct 17 '13 at 23:21

In aptitude you filter just the packages that are deinstalled but still have configuration files remaining (which are in state 'c').

  1. press L

  2. filter for ~c

  3. purge all listed packages by pressing _

share|improve this answer

I found this answer the simplest.

The following should do what you want:

aptitude purge \~c

This purges all packages with the c (package removed, configuration files still present) state flag. Flag documentation is here.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .