Many times I find the command-line utilities for package management faster and more convenient than GUI tools like Synaptic or Adept. Yet learning how to use them efficiently takes time. Here’s a trick you can use to purge packages that have already been removed with apt-get remove
or aptitude remove
. When a package is uninstalled, its configuration files are left on the system, in case you’ll want to install it again. Purging a package gets rid of these configuration files. This not only frees disk space, but also helps maintain the system clean. It’s easy to forget to add --purge
to each apt-get remove
command you run, but there’s an easy way to purge packages after you’ve removed them:
dpkg -l |awk ‘/^rc/ {print $2}’ |xargs sudo dpkg --purge
What this does is run a dpkg -l
to list packages, select all lines that begin with “rc
” (which means the package is removed, but its config files are still on the system), and pass them to dpkg --purge
to get rid of them. Neat, huh?
NOTE: If you don’t use sudo
, remove it from the command above and run the whole line as root
.
[…] by superpiwi in Tips, Linux, Ubuntu. trackback Un truco interesante que me encuentro en esta pagina y que aparte de hacernos ganar algo de espacio en disco, tambien ayuda a mantener el sistema mas […]
[…] i file di configurazione di pacchetti rimossi 9 10 2008 Ho appena scoperto un piccolo trucchetto che permetti di rimuovere tutti i file di configurazione di pacchetti […]
Nice tips!!
Thanks very much for this, extremely useful!
[…] APT Tip: Purge Removed Packages « exit’s /dev/urandom blog a few seconds ago from Adium […]
thanks dude
Another way of handling this is using just aptitude.
aptitude purge $(aptitude search ~c -F %p)
purge all packages with the ‘c’ flag (“the package was removed, but its configuration files are still present.” [1]) by printing only the package name
[1] http://algebraicthunk.net/~dburrows/projects/aptitude/doc/en/ch02s02s02.html,
Very cool! Didn’t know about that form of invoking aptitude.
Thank you! Very helpful.
I found out later that it could be done even simpler:
aptitude purge ~c
This simply purges all packages with the c flag.
Nice!
[…] purge を使わずに削除したパッケージは設定ファイルだけが残ってしまう。この設定ファイルのみを削除する方法もあるようだ。こちらで紹介されている。APT Tip: Purge Removed Packages « exit’s /dev/urandom blog こいつは便利! […]
[…] Original article here: https://ascending.wordpress.com/2007/04/10/apt-tip-purge-removed-packages/ […]