Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

As an Ubuntu noob, I install and uninstall a lot of packages, to try them out. However, for months, I made the mistake of using apt-get remove instead of apt-get purge, which I didn't even realize exists.

Is there a way to cause apt-get to purge every package I've uninstalled? My system is full of leftover files I neither want or need from dozens of different packages.

share|improve this question
It's not a "mistake" to do this. The difference between remove and purge is that the latter deletes configuration files at the system level. Your user configuration files are not affected by either method. As very few programs use system-level configurations, for most programs the two commands would in practice be identical. Further, any configuration files take very little space, and so there is in fact nothing for you to worry about. – Paddy Landau Sep 4 '12 at 11:56
@PaddyLandau: Since many of these packages were services and did in fact have system configuration, I had a lot of files left. It was a mistake in this case, because I had thought remove does remove these configuration files. – configurator Sep 4 '12 at 12:05
up vote 20 down vote accepted

A simpler alternative, using aptitude (not installed by default)

sudo aptitude purge '~c'

~c is an aptitude search pattern, it means 'Select packages that were removed but not purged'. (The single quotes are to prevent the possible expansion of ~c by the shell as the home directory of a user c.)

Note that purging will remove system configuration files, usually located in /etc, but personal configuration files, usually in some hidden directory in your home, are not removed (it is not always simple to know which they are).

share|improve this answer
What does ~c mean here? – configurator Aug 29 '12 at 21:31
@configurator: it is an aptitude's search pattern, it means 'Select packages that were removed but not purged', see aptitude documentation. – enzotib Aug 29 '12 at 21:43
Thanks! This is an even simpler answer so great :) – configurator Aug 29 '12 at 21:57
Strictly speaking, \~c might be considered preferable, as it will work even if there is a user called c (in which case ~c would be expanded by the shell to /home/c or whatever else is c's home directory, before being passed to aptitude). – Eliah Kagan Aug 29 '12 at 22:55 says:

dpkg -l | grep '^rc' | awk '{print $2}' | xargs dpkg --purge
share|improve this answer
if you have uninstalled OpenJDK JRE it's really useless – obysr Aug 29 '12 at 21:11
Thanks, that's exactly what I was looking for. – configurator Aug 29 '12 at 21:30
This should also work dpkg -l | awk '/^rc/ {print $2}' |xargs sudo dpkg --purge – Anwar Shah Sep 11 '12 at 16:14

those two will clean your packages, but you should get in the habit of using this,

sudo apt-get remove --purge <package name>

that will purge the packages.

also check this out, this an utility called ubuntu-tweak, it has a feature that is called janitor, that lets you see the packages to clean, and even the configs.

share|improve this answer
autoclean and autoremove have nothing to do to wath OP asked – enzotib Aug 29 '12 at 20:59
does this edit answer it now? – kmassada Aug 29 '12 at 21:04
Removed the -1, but it doesn't answer, because the OP already know how to do for the future, it ask for already installed packages. – enzotib Aug 29 '12 at 21:05
+1 for mentioning Ubuntu Tweak. It's what I use to clean my systems and it provides a nice GUI for selecting exactly what I want cleaned and what I want to keep. – Christopher Kyle Horton Sep 10 '12 at 11:08

I use Ubuntu-Tweak to do this job.

  1. Install Ubuntu tweak

  2. Open it by typing "Ubuntu-tweak" in the dash. To open dash, press Super key.

    Ubuntu tweak in dash

  3. Go to the janitor tab, Click on the Package Configs in the left bar, then put a Tick mark at the right section of window and then click the Clean button. This will ask administrative password, give it and wait for a while....... Your system is clean from old configs.

    cleaning in ubuntu tweak

share|improve this answer

As an alternative to the other answers, you can remove any leftover configuration files by using the BleachBit utility (click to install).

share|improve this answer

Your Answer


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.