Remove Old Package Configuration Files in Ubuntu

September 21, 2011 by
Filed under: command line, HowTo, linux, Ubuntu 

Many software packages in Ubuntu come along with a package configuration file. These files are used to control various settings for their particular package. In most cases, there is no reason to keep these files around after you've removed a package from you system. They get removed from your system along with the software package if you happen to use the apt-get purge command or if you mark it for "Complete Removal" in Synaptic. But what if you didn't do that when you removed the package?

One thing you can do is reinstall the package and then purge it from your system, but there's got to be a better way. Well, it turns out that you can use the dpkg command to do the job. You actually use dpkg twice: once to find the orphaned configuration files, and again to actually remove the files. The following command has been tested on Ubuntu 10.04 and 10.10, but it should work on any Debian or Ubuntu based Linux distribution.

dpkg -l | awk '/^rc/{ print $2}' | sudo xargs dpkg --purge


4 Responses to “Remove Old Package Configuration Files in Ubuntu”

  1. Douglas says:

    Tried to remove it...and the file avast.desktop is still in my system files!!!!

  2. euclid says:

    Amazing...I was sick and tired of seeing those old file lurking around. One by one was not going to work and BleachBit was confusing. Genius..Sir...Genius!

  3. Dave Nelson says:

    Stupid question, but how do I obtain the command prompt in Ubuntu so I can send this command?

    I know, Ubuntu for dummies!

    • Linerd says:

      If you're using the latest Ubuntu with the Unity desktop, you should be able to get it by opening the Dash (Ubuntu logo in the upper left corner), and then just enter "terminal" in the search box. You might get a couple of choices. Pick gnome-terminal. You might also be able to get to it with [Ctrl]+[Alt]+[T], but I'm not sure if that shortcut works. A third option is to hit [Alt]+[F2] and enter gnome-terminal and you should get a terminal window popping up.

      Sorry if some of this info ends up incorrect, but I'm sitting at a Windows-only machine right now.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>