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

Comments

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

  1. Matt says:

    I just did a system upgrade to ubuntu LTS 14.04, and I've got a whole slew of packages marked "deinstall" as their listed status in the output of dpkg --get-selections:


    > dpkg --get-selections | grep deinstall

    apache2.2-common deinstall
    consolekit deinstall
    libapt-inst1.4:amd64 deinstall
    libbind9-80 deinstall
    libdconf0:amd64 deinstall
    libdns81 deinstall
    libdrm-nouveau1a:amd64 deinstall
    libgdu0:amd64 deinstall
    libgnome-keyring0:amd64 deinstall
    libicu48 deinstall
    libisc83 deinstall
    libisccc80 deinstall
    libisccfg82 deinstall
    libllvm3.0:amd64 deinstall
    liblvm2app2.2:amd64 deinstall
    liblwres80 deinstall
    libmpc2:amd64 deinstall
    libopenmpi1.3 deinstall
    libpangox-1.0-0:amd64 deinstall
    libpangoxft-1.0-0:amd64 deinstall
    libsgutils2-2 deinstall
    libtasn1-3:amd64 deinstall
    libtiff4:amd64 deinstall
    libtokyocabinet8 deinstall
    libudev0:amd64 deinstall
    linux-image-3.11.0-15-generic deinstall
    ocl-icd-libopencl1:amd64 deinstall
    udisks deinstall

    I have two questions.

    1) What is the exact meaning of the "deinstall" status? I know for a fact a that at lease some of these they have already been removed, but config files have been left hanging around. Is that true for all of these packages?

    2) If the answer to 1) is yes, then is it truly safe to go ahead and purge all of these packages?

    Thanks!
    Matt

  2. Douglas says:

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

  3. 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!

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