How I cleaned up my Ubuntu server

👋 Ciprian on Tuesday, September 19, 2017 in Blog
Last modified on Friday, September 15, 2017

Learn JavaScript by example. Code snippets, how-to's and tutorials. Try now!

Remember to backup 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 fulfill dependencies to other packages, so not installed explicitely, which allows to remove 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 removes 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.

Buy me a coffee to support my work!

👋 Added by Ciprian on Tuesday, September 19, 2017 in Blog. Last modified on Friday, September 15, 2017.

Leave a Reply

You have to agree to the comment policy.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Privacy Policy