HOWTO Clean packages on a Debian system

This article was first written in July 2005 for the BeezNest technical
website (
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.
$ deborphan
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


2013, 17 November

For what it's worth, Sun java appears removed from repositories configured for out of the box use:

sudo apt-get install sun-java6-jdk tomcat6 maven2 postgresql
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package sun-java6-jdk is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'sun-java6-jdk' has no installation candidate

I've never had success installing Tomcat from repositories, and I will not build a custom deal and risk breaking the server.

Java is really an unfriendly player.

In reply to by YW


Why don't you just use OpenJDK if for Tomcat only?