Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I was doing a package removal with apt-get remove but then realized I should have done a --purge along with it to remove the configuration files.

Can I remove the packages configuration files easily or do I need to reinstall the package and then remove with a --purge?

share|improve this question
add comment

4 Answers

up vote 14 down vote accepted

Yes you can.

From the command line:

sudo apt-get remove --purge packagename

This will remove all of the remaining files that the package installed.


You can also do this from a GUI:

  • Install Synaptic Install Synaptic from the Software Center
  • Run Synaptic
  • Find packages listed under "Not Installed (residual config)"
    Packages with residual configs
  • Right click the package and click, mark for complete removal Menu
  • Click the check button on the tool bar and click apply when the dialogue pops up. Dialogue
share|improve this answer
add comment

Here is a command will fill your request.

dpkg --purge `dpkg --get-selections | grep deinstall | cut -f1`
share|improve this answer
add comment

Yes!

Whilst waiting for more in depth technical answer as I don't have a clue about the internals of Ubuntu!

Tested this on apache2.2-common and mediawiki.

Performing apt-get remove left some files, trying to perform the command again resulted in an error saying that the package was not installed, however, it was available on tab completion for apt-get remove.

When I did apt-get remove apache2.2-common --purge, this both removed the left over files and removed it from the tab completion.

Again, can only give the answer and not a technical "why", but, I look forward to reading someone else's answer!

share|improve this answer
add comment

The commands

apt-get purge

and

apt-get remove --purge  

work for removed packages only in newer versions of apt. In older versions, you need to use:

dpkg --purge packagename  

in order to work.

Also I noticed in newer versions tab-completion doesn't work with not purged packages when you're trying to remove or purge them.

share|improve this answer
1  
In 12.04 and later, the commands work as expected, so I'm not sure why this comment is here. I should also point out that if there are issues with tab-completion then you should report that as a bug rather than state that as a comment. –  Thomas W. Jan 18 at 18:53
    
There is many systems –  Luisg123v Jan 18 at 19:12
    
This site is only for Ubuntu. Not other variants of Linux. In Ubuntu, 12.04, 12.10, 13.04, 13.10, and even 10.04, the only supported old old release still, this works as intended, so there's no real need to mention "older versions". –  Thomas W. Jan 18 at 19:15
    
There is many systems running with versions of apt where the command wouldn't work, for example, i just tried in ubuntu 10.04 and it didn't (actually it was my trouble), so it whould be useful to know it. In addition, tab-completion is not necessarily a bug, but a vehavior that could be interesting to know. –  Luisg123v Jan 18 at 19:25
    
Given that 12.04 is for the most part EOL now, I'd be surprised to see a still-used 12.04 system outside of outdated servers. –  Thomas W. Jan 18 at 20:15
show 1 more comment

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.