Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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.

share|improve this question
    
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 5: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 Answers 4

up vote 11 down vote accepted

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
    
Sorry, it's not working line 1> # sudo aptitude purge '-c' line 2> aptitude: invalid option -- 'c' –  Alexandre Martins Mar 27 '12 at 15:10
3  
@AlexandreMartins The first character in the quotes is a tilde, not a hyphen. –  Chris Down Mar 27 '12 at 15:11
    
Forgot to say thanks. It worked. –  Alexandre Martins Mar 28 '12 at 17:44

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)
share|improve this answer
    
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

For those who don't want to install aptitude:

sudo dpkg -P $(dpkg -l | awk '/^rc/ { print($2) }')
share|improve this answer
aptitude --clean-on-startup

That should clear the package cache.

share|improve this answer
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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.