16

To be more specific, I would like to do the equivalent of adding the --purge flag to the following command

sudo apt-get autoremove --purge [package name]

to packages that are no longer on the system.

Preferably, I would like to know how to do it to specific packages and to every uninstalled package in the system.

Faheem Mitha
  • 34,649
  • 32
  • 119
  • 183
  • The question is not clearly worded. I assume you mean - "how does one remove configuration files from packages that have been removed from the system, but still have configuration files installed". Bringing in `autoremove` is just confusing, imo. – Faheem Mitha Mar 28 '12 at 05:20
  • @FaheemMitha Changed the title according to your suggestions. But I think the autoremove only would make things confusing if I didn't write anything else. But the sentence "I would like to do the equivalent of adding the --purge flag to the following command" makes things clear. – Alexandre Martins Mar 28 '12 at 18:19

4 Answers4

19

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.

Chris Down
  • 122,090
  • 24
  • 265
  • 262
8

For those who don't want to install aptitude:

sudo dpkg -P $(dpkg -l | awk '/^rc/ { print($2) }')
2

The --purge flag removes configuration files for packages that are no longer installed. I don't recommend blindly removing configuration files for all uninstalled packages. You might want to keep some of them. For an individual package, dpkg -P will work (-P stands for --purge). Here alacarte only has its configuration files installed, hence the rc flags. E.g.

orwell:/home/faheem# dpkg -l alacarte
[...]
rc  alacarte                           0.11.5-1                           easy GNOME menu editing tool
orwell:/home/faheem# dpkg -P alacarte
(Reading database ... 345418 files and directories currently installed.)
Removing alacarte ...
Purging configuration files for alacarte ...
orwell:/home/faheem# dpkg -l alacarte
[...]
un  alacarte                           <none>                             (no description available)
Faheem Mitha
  • 34,649
  • 32
  • 119
  • 183
  • Usually, I keep the important configurations in my own home folder. This means the --purge flag does not do anything problematic to me. And it actually helps me not having any problems later on. Is there any good reason you say I shouldn't use --purge that I'm missing? – Alexandre Martins Mar 28 '12 at 17:51
  • 1
    @AlexandreMartins: If you are sure you don't have any configuration in any of the system config files, that is fine, I guess. That is definitely not the case for me though. – Faheem Mitha Mar 28 '12 at 21:33
-1
aptitude --clean-on-startup

That should clear the package cache.

SuperBOB
  • 212
  • 1
  • 3
  • 3
    Following the manuale page: "Cleans the package cache when the program starts". This is not what the OP asked. – enzotib Mar 27 '12 at 16:39