This article was first written in July 2005 for the BeezNest technical website (http://glasnost.beeznest.org/articles/282).
A Debian system can take more and more disk space as you install new packages. Let’s see how we can detect which packages are no longer used (unsused/obsolete/transitional) and clean them if we are sure we don’t need them anymore.
First, it is good to know that when you use apt (apt-get, aptitude, dselect, synaptic, …) the files downloaded are stored in /var/cache/apt/archives, and never cleaned. To clean them, use the following:
- to clean obsolete packages (packages of version which would not be installed if requested now)
$ sudo apt-get autoclean
- to empty all /var/cache/apt/archives/*.deb
$ sudo apt-get clean
If using aptitude, it keeps a track of packages taken to fulfill dependencies to other packages, so not installed explicitely, which allows to remove packages when the package that needed it is removed.If using another apt tool, it does not keep such information, so there are probably dependencies left after a removal.
To keep track anyway of these dependencies, Debian provides the debfoster tool.
To detect such orphaned packages, Debian provides the deborphan tool.
When used without parameters, it only lists the libraries on which no package depends.
I suggest using the following parameters, which list all orphaned packages, with their respective sizes (works only starting from Sarge).
$ deborphan -az
And I personally sort them to first remove the biggest ones.
$ deborphan -az | sort -n
There are lots of locales supported by Debian packages, which may take up quite a lot of disk space. The Debian tool localepurge permits to wipe the unused locales.
When upgrading from one Debian release to another, some packages maybe left without being of any use, and are pretty difficult to track. To detect them, Debian provides the apt-show-versions tool.
There are also many transitional dummy packages that exist only for the upgrade to happen smoothly. To detect them:
$ dpkg -l|grep dummy $ dpkg -l|grep transitional $ dpkg -l|grep obsolete