Once in a while, you may want to do some maintenance on your Ubuntu machine and clean up unnecessary files that are chunking up large storage space in your hard disk.
Here are 8 ways that you can use to clean up your Ubuntu:
1) Analyze your disk usage
The first thing that you need to do is to find out which files are consuming the large bulk of the storage space in your hard disk. Go to Applications->Accessories->Disk Usage Analyzer and click on the Scan Filesystem at the top to get it to analyze your disk usage pattern. You will be able to see instantly which files/folders are taking up the bulk.

Once you have determined the files that are taking up large storage space, you can do the following:
- decide if you have any use of the files. If not, send them to the trash.
- If you have no immediate use of the file, but will need to reference to it in the future, either backup to a CD/DVD or to an external hard disk. If the file is too big, you may want to compress and split it to several small files for easier storage.
2) Clear duplicate files and broken symlinks
Over the time, you could have dozen copy of the same file lying in different corners of your system. The best place is to hunt them down and eliminate them before they take control of the hard disk.
FSlint is a utility to find and clean various forms of lint on a filesystem, especially duplicate files and broken symlinks.
Install fslint, or via the terminal:
sudo apt-get install fslint
Go to Applications-> System Tools-> FSlint. Add the file path that you want to search. On the left, click on the Duplicate tab and click Find at the bottom.

Other than finding duplicate files, FSlint can also find broken symlinks, empty directories, bad IDs and even redundant temp files, all of which you can delete and recover back your precious disk space.
3) Clean up your package installation
If you have installed and uninstalled a lot of applications, chances are your system is infected with a lot of dependencies files that you have absolutely no use for. Here are some useful commands to get rid of any partial package and remove any unused dependencies:
Cleaning up of partial package:
sudo apt-get autoclean
Cleaning up of the apt cache:
sudo apt-get clean
Cleaning up of any unused dependencies:
sudo apt-get autoremove
A good practice to avoid any left behind is to use the autoremove command whenever you want to uninstall an application.
sudo apt-get autoremove application-name
4) Get rid of old residual config package
When you upgrade a software to a later version, the package of its previous version will still be left behind in the system. You will be able to free up some space by eliminating the old residual config package
Open up your Synaptic Package Manager (System-> Administration-> Synaptic Package Manager). On the left, click on the Status button. You will see a few options appear on the top left pane. If there is a Not Installed (residual config) option, click on it. This will reveal all the residual config package in the system.

Check the box beside the package and select “Mark for complete removal”. Click Apply.

5) Remove orphaned package
Other than the dependencies files, packages can also become orphaned when you uninstall an application. To get rid of orphan files, we can make use of gtkorphan, a graphical frontend for deborphan.
Install gtkorphan or via the terminal:
sudo apt-get install gtkorphan
Go to System-> Administration-> Removed Orphaned package

It will analyze the system and show all the orphaned package in the main window. Check those packages that you have no use for and uninstall them.
6) Keep track of what you have installed
Debfoster creates a dependency files to enable you to keep track of what you have installed. When you uninstall an application, it will check for any leave behind dependencies files or orphaned packages and ask you if you want to remove it.
Install debfoster, or via the terminal,
sudo apt-get install debfoster
Creating the initial keeper file:
sudo debfoster -q
Force the system to conform to the keeper file
sudo debfoster -f
If you have some packages that you never want to uninstall and do not want debfoster to handle those packages, you can edit the keeper file and remove those packages from the list.
gksu gedit /var/lib/debfoster/keepers
To see is there is any orphaned package or dependencies files that need to be removed:
sudo debfoster
7) remove locale files
Unless you have a need to switch to various locales all the time, you can uninstall the unused locales and free up some amount of the storage space in your system.
Install localepurge, or via the terminal:
sudo apt-get install localepurge
Once the installation is done, it will remove all locale files from your system that you have no need for.

8) Clean up grub menu (only for those who know what they are doing)
Sometime when you perform an update, you will find that the kernel is being upgraded to new one while the old one still remain. If you don’t like to see a long list of entries in your grub menu when you boot up the computer, here is a simple way to clean up the grub menu.
Go to terminal and type
gksu gedit /boot/grub/menu.lst
Search for the following lines:

Remove the entry that you have no need for. Save and exit.
Rather than editing the menu.lst file which can be a scary task for newbies, an easier and better way to cleanup the grub menu is via Startup Manager or SUM in short.
Install SUM or in your terminal:
sudo apt-get install startupmanager
Go to System-> Administration-> Startup-Manager
In the Boot Option tab, under the Default Operating System field, pick the kernel that you want to use.

Click on the Advanced tab, check the box Limit the number of kernel in the boot menu. In the Number of kernels to keep field, enter 1

Close the window.
You should see a cleanup grub menu the next time you boot up.
Is there any ways that I have missed out? How do you clean up your Ubuntu machine?
It’s been long time I’ve not use ubuntu for my assignments. It’s about time to switch back. ^^
Should make use of apt: links, eh :)
These are some great tips – I’ve never even thought to clean things up but I’m sure the increased productivity would be worth the time investment.
I expected to see things like “never install packages directly from source, use checkinstall.”
Seriously, if there’s one thing that’ll clutter stuff up, it’s that, because you can whip out all your crazy apt tricks, but, surprise! It’s not even /in/ apt.
best post about ubuntu in a long time, thanks!
9. Format machine and install Windows Vista on it.
I did the opposite way , remove Vista installed Ubuntu
You don’t have to edit the grub config file directly. You can just install startupmanager via apt-get.
Here’s another great tool, dpigs:
sudo apt-get install debian-goodies
dpigs -N 10
^^ will show you the top 10 most bloated packages installed on your system. Awesome way to start trimming the fat..
May I suggest Start-Up Manager for the grub section. It’s a gui utility for editing the menu.lst file. Just do an apt-get install startup manager. I also suggest keeping only 2 kernels, using that automatic option.
Why are you using Fedora’s theme for ubuntu?
Or just use Archlinux ;-)
When you inevitably screw up editing the grub menu and the computer won’t boot properly any more, then get download Super Grub Disk to help sort it out :-)
http://supergrub.forjamari.linex.org/
well, i don’t get it: whats the difference between orphaned packages and forgotten to remove dependencies?
and i guess ubuntu documentation recommends using aptitude (all the time, so it can build installed package database) instead of debfoster, gtkorphan and so on.
# aptitude install somepackage
# aptitude purge –purge-unused somepackage
As a relatively new ubuntu user, I found this guide very useful. Thanks for the tips!
Great article. This is actually what I do normally.
If anyone does not like to use command to clean/autoremove, do it via gjig (I don’t use it.).
And I prefer to edit GRUB menu manually:)
Great work! Guys.
Great article! It was very helpful!
Thanks! :D vladimir@bcc.ufla.br
Thanks so much for the article. It surely was of great help to me as am a newbie.
I’m new to Ubuntu, so this article is of great help.
Thank You
You are welcome
http://bleachbit.sourceforge.net/ should be helpful too.
Thanks for this guide! I did have one odd occurrence… running autoremove flagged and deleted my packages for Skype, so I had to reinstall it. I assume this has something to do with the fact that it uses 32 bit libraries (even though I am using the 64 bit package from medibuntu), and my OS is 64 bit.
Here’s a question: I have a two entries of “OpenJDK Java 6 Web Start” under my Applications>Internet pull down menu… how do I get rid of one of them? Unlike the panel, right-clicking does bring up a “remove” option.
“Here’s a question: I have a two entries of “OpenJDK Java 6 Web Start” under my Applications>Internet pull down menu… how do I get rid of one of them? Unlike the panel, right-clicking does bring up a “remove” option.”
Go to System > Preferences > Main Menu
This should bring up a GUI to edit the things that appear in the menus. Find your duplicate item and untick it. Bingo :-) Have fun.
Wow, I’ve been using Ubuntu for a long time (since Dapper), and have read a lot of articles on tweaking it. This is the first I’ve seen mention Start-Up Manager. Why the heck isn’t this installed as a default app in Ubuntu? I know “average joe” users could hurt themselves with it, which would be obvious, but power-users would definitely want to see this. They need to make a “dumbed down” and “power user” mode for Ubuntu, so your parents won’t hurt themselves using it, but you’ll have all the tools you’ll need if you have to trouble-shoot their comp later.
Well, actually those “power users” won’t need that SUM… I found myself much more comfortable editing configuration text files than having a GUI messing up my configs. I think that’s why they don’t have it by default: People who knows how GrUB works won’t need a GUI to config it.
Thank you a lot, have been looking for this kind of indepth maintenance analysis for a long time!
Nice guide! I would add that removing old kernels frees up a couple of hundreds of megabytes, too.
You should put Computer Janitor there too…
Wait, you forgot something. system is running slow. Solution: reformat windows and try again. Next day….system is corrupted, windoze will not boot. Solution: reformat and try again. Better solution: USE LINUX!!!
Hello!
Good post and thanks for it!
No way will I install Vista on my PC again.