How I cleaned up my Ubuntu server

on in Blog
Last modified on

Remember to back up or create a snapshot of your system before performing the steps below!

apt-get install aptitude

apt-get autoclean

apt-get autoremove

Aptitude keeps a track of packages taken to fulfil dependencies to other packages, so not installed explicitly, which allows removing packages when the package that needed it is removed.

To detect orphaned packages, use the deborphan tool.

When used without parameters, it only lists the libraries on which no package depends.


There are lots of locales supported by Ubuntu packages, which may take up quite a lot of disk space. The localepurge tool permits to wipe the unused locales.

If you uninstall stuff with apt-get remove, sometimes Ubuntu does not remove config files, and they also take up space. Now, you can just use apt-get purge. If you haven’t used it for every remove, this command lists all the packages which are removed but still have config files on your system:

dpkg --list | grep '^rc '

Remove them using:

deborphan --find-config | xargs dpkg --purge

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

Use apt-get to remove the ones that you don’t need, but pay attention to their dependencies. You might end up deleting your entire Linux image.

apt-get autoremove

apt-get update

apt-get upgrade

Your system is now lean and smooth. reboot it when you are done.

Related posts