4

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.)

3 Answers 3

4

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}'); 
do 
  dpkg -L $pkg; 
done

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

4
  • 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… Commented Jul 13, 2012 at 19:00
  • Hmm. Did you try dpkg -L on these packages? Does it show any files?
    – nik
    Commented Jul 13, 2012 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. Commented Jul 18, 2012 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.
    – Hakanai
    Commented Oct 17, 2013 at 23:21
3

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 _

3

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.

You must log in to answer this question.

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