How to clean ubuntu
How to clean ubuntu
How to Clean Your Ubuntu Machine
In general, Linux-based operating systems, like Ubuntu, manage computer resources quite well. However, sometimes users install many programs and don’t uninstall them afterwards, which leads to reduced memory and fragmented disk. As a result, the operating system may slow down. To avoid this, start disk cleaning and enhance the computer’s performance.
Before presenting some ways of cleaning your Ubuntu, let’s see how you can check free space in your system.
Check free space
The first thing you need is to find out which files are consuming the large bulk of the storage space in your disk. Use the Disk Usage Analyzer tool. Run the tool, and you will see the used and free space. After that, you can clear your system.
Uninstall unnecessary applications
Probably you have many applications that you don’t use any more. Uninstall the application with the following command:
Or, if you want to do the same without a command line, use the Ubuntu Software manager, where you’ll only need to click the «Remove» button.
Clean unnecessary packages and dependencies
Updating your system via the default updating tool can lead to the accumulation of packages that will fill the cache. This can mainly occur when you uninstall software packages, but their dependencies are left without any reason at all.
To remove the dependencies left behind once installed packages that aren’t needed any longer, use this command:
Clean the thumbnail cache
There are thumbnails used by Ubuntu to make some operations on your computer to perform them faster. They are like cookies and cache in browsers.
The thumbnails increase over time, and the computer does not clear them automatically. Instead, Ubuntu has a command to clear them.
Clean the Apt cache
APT (Advanced Package Tool) cache is the place where all the downloaded, installed, and uninstalled files of your system are kept. Ubuntu keeps them in your /var/cache/apt/archives directory.
Or, you can also clean up only absolutely not necessary packages that can’t be found in the repositories any more, or they have new versions located:
Remove orphaned package
Besides the dependencies files, packages can also become orphaned when you uninstall an application. To get rid of orphan files, you can make use of «gtkorphan», a graphical interface for «deborphan». Use this command:
Remove unnecessary kernels
If old kernel versions remain on your disk (which can depend on how your system is set up), you can try the following command:
Remove locale files
Unless you need to switch to several locales all the time, you can uninstall the unused ones and free up some storage space in your system.
You can either install the localepurge package or use the following command:
Once the installation is done, it will remove all locale files from your system that you have no need for.
Simple Ways to Free Up Space in Ubuntu Linux
Disclosure: This post may contain affiliate links, which means we may receive a commission if you click a link and purchase something that we recommended.
Ever running out of disk space in your Ubuntu server or system, you can follow the below simple ways to free up space and clean your Ubuntu.
In thins guide you are going to learn how to clean up cache, old kernels, remove unused packages, journal logs.
Prerequisites
Access to server or system with root user or a user with sudo access.
Step 1: Remove APT Cache
Ubuntu keeps a cache of the installed packages which are downloaded or installed earlier even after uninstallation. You can see the cache files in this location /var/cache/apt
To check the disk space consumed you can use the following command.
Your will get an output that shows the space used by the cache folder.
Now you can clean this cache using the following command.
This command will clean up the entire cache which frees up more space.
If you wish to clean up only the outdated packages, you can use the following command.
Step 2: Clean Journal Logs
Each Linux disto has their own logging system to investigate what is going on in the system. You will have all logging data related to kernel or any other services.
Over time these logs consume more space. You can check the log size using the following command.
You can clear these logs which are older than certain days using the following command.
This command will delete all logs that are older than 2 days.
Step 3: Clean Up unused Packages
If you have packages that are not used you can use the following command to remove these packages.
Step 4: Remove Old Kernels
You can remove the kernels that are no longer needed and that are installed from Ubuntu archive while system updates using the following command.
This command will not remove the kernels that are installed manually.
Conclusion
Now you have learned how to clean up your Ubuntu server or system by cleaning the journal logs, cache, unused packages, old kernels.
Thanks for your time. If you face any problem or any feedback, please leave a comment below.
7 Simple Ways to Free Up Space on Ubuntu and Linux Mint
Brief: Running out of space on your Linux system? Here are several ways you can clean up your system to free up space on Ubuntu and other Ubuntu based Linux distributions.
Over time, any operating system can become cluttered as programs are added and removed. If you have like a TB of storage capacity, you might not bother to clean up Ubuntu to make some disk space. But if your hard disk has limited space, like I have a 128 GB SSD laptop, freeing up disk space becomes a necessity.
In this article, I’ll show you some of the easiest tricks to clean up your Ubuntu system and get more space. I’ll also share some advanced tricks so that you’ll have choices.
But before that, let’s see how to find the free space remaining on Ubuntu.
Check free space on Ubuntu
It’s always a good idea to check the free disk space in Linux first. This is rather easy on Ubuntu. Just use the Disk Usage Analyzer tool. Search it in the menu and run the tool. You should see the disk space used and the free space remaining here:
Once you know the state of free space on your disk, it’s time to clean up your system and make some more free space here.
How to free up disk space in Ubuntu and Linux Mint
There are several ways you clean up disk space in Ubuntu and other Ubuntu-based system. I have discussed several command-line tricks here followed by some GUI options.
While I have mentioned several ways here, if you are a beginner, avoid the ones marked as ‘expert’. Not that you cannot use them, but it’s better to avoid them if you don’t know what you are doing.
I am using Ubuntu 16.04 while writing this tutorial but you can use the same steps for Ubuntu 18.04 and other Ubuntu versions, Linux Mint, elementary OS, and other Ubuntu-based Linux distributions.
If you prefer videos, I have made a video to show you how to clean Ubuntu.
As you can see, this command is going to free up 300 Mb of free space in my system.
» data-medium-file=»https://itsfoss.com/wp-content/uploads/2017/06/clean-up-space-ubuntu-linux-1-300×112.png» data-large-file=»https://itsfoss.com/wp-content/uploads/2017/06/clean-up-space-ubuntu-linux-1.png» width=»732″ height=»273″ src=»https://itsfoss.com/wp-content/uploads/2017/06/clean-up-space-ubuntu-linux-1.png» alt=»Free up space with autoremove command» data-lazy-srcset=»https://itsfoss.com/wp-content/uploads/2017/06/clean-up-space-ubuntu-linux-1.png 732w, https://itsfoss.com/wp-content/uploads/2017/06/clean-up-space-ubuntu-linux-1-300×112.png 300w» data-lazy-sizes=»(max-width: 732px) 100vw, 732px» data-lazy-src=»https://itsfoss.com/wp-content/uploads/2017/06/clean-up-space-ubuntu-linux-1.png?is-pending-load=1″ srcset=»data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7″> Free up space with autoremove command
2. Uninstall unnecessary applications [Recommended]
We all have a few games and/or applications that we hardly use. Don’t trust me? Go and find all the installed software on your Ubuntu system.
» data-medium-file=»https://itsfoss.com/wp-content/uploads/2017/06/find-installed-software-ubuntu-300×206.jpeg» data-large-file=»https://itsfoss.com/wp-content/uploads/2017/06/find-installed-software-ubuntu.jpeg» width=»799″ height=»549″ src=»https://itsfoss.com/wp-content/uploads/2017/06/find-installed-software-ubuntu.jpeg» alt=»Find installed software in Ubuntu» data-lazy-srcset=»https://itsfoss.com/wp-content/uploads/2017/06/find-installed-software-ubuntu.jpeg 799w, https://itsfoss.com/wp-content/uploads/2017/06/find-installed-software-ubuntu-300×206.jpeg 300w, https://itsfoss.com/wp-content/uploads/2017/06/find-installed-software-ubuntu-768×528.jpeg 768w» data-lazy-sizes=»(max-width: 799px) 100vw, 799px» data-lazy-src=»https://itsfoss.com/wp-content/uploads/2017/06/find-installed-software-ubuntu.jpeg?is-pending-load=1″ srcset=»data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7″> You can find installed apps in Software Center
Chances are that you have a number of apps installed that you seldom use. Maybe you installed them on the back of an awesome review, out of nosiness, or to handle a particular task.
If you need space more getting rid of the unused or lesser used applications is always a good idea.
You can remove a program in Ubuntu from the software centre or use the command below with the particular app names:
3. Clean up APT cache in Ubuntu
Ubuntu uses APT (Advanced Package Tool) for installing, removing and managing software on the system, and in doing so it keeps a cache of previously downloaded and installed packages even after they’ve been uninstalled.
The APT package management system keeps a cache of DEB packages in /var/cache/apt/archives. Over time, this cache can grow quite large and hold a lot of packages you don’t need.
You can see the size of this cache with the du command below:
As you can see, I have over 500 Mb of cache storage. When you are almost out of space, this 500 Mb can make a lot of difference.
» data-medium-file=»https://itsfoss.com/wp-content/uploads/2017/06/clean-up-space-ubuntu-linux-2-300×50.png» data-large-file=»https://itsfoss.com/wp-content/uploads/2017/06/clean-up-space-ubuntu-linux-2.png» width=»732″ height=»122″ src=»https://itsfoss.com/wp-content/uploads/2017/06/clean-up-space-ubuntu-linux-2.png» alt=»Clean up cache in Ubuntu Linux» data-lazy-srcset=»https://itsfoss.com/wp-content/uploads/2017/06/clean-up-space-ubuntu-linux-2.png 732w, https://itsfoss.com/wp-content/uploads/2017/06/clean-up-space-ubuntu-linux-2-300×50.png 300w» data-lazy-sizes=»(max-width: 732px) 100vw, 732px» data-lazy-src=»https://itsfoss.com/wp-content/uploads/2017/06/clean-up-space-ubuntu-linux-2.png?is-pending-load=1″ srcset=»data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7″> Cleaning up cache will free up space
Either remove only the outdated packages, like those superseded by a recent update, making them completely unnecessary.
Or delete apt cache in its entirety (frees more disk space):
4. Clear systemd journal logs [Intermediate knowledge]
Every Linux distribution has a logging mechanism that helps you investigate what’s going on in your system. You’ll have kernel logging data, system log messages, standard output and errors for various services in Ubuntu.
The problem is that over time, these logs take a considerable amount of disk space. You can check the log size with this command:
Now, there are ways to clean systemd journal logs. The easiest for you is to clear the logs that are older than certain days.
Here’s an example:
5. Remove older versions of Snap applications [Intermediate knowledge]
You probably already know that Snap packages are bigger in size. On top of that, Snap stores at least two older versions of the application (in case, you want to go back to the older version). This eats up a huge chunk of space. In my case, it was over 5 GB.
Alan Pope, part of Snapcraft team at Canonical, has created a small script that you can use and run to clean all the older versions of your snap apps.
What you have to do here is to create a new shell script and use the following lines in your script:
Give it execute permission, run the shell script with sudo and see the magic. The script removed the older Snap packages and freed over half of the 5 GB space used by Snap.
6. Clean the thumbnail cache [Intermediate knowledge]
Ubuntu automatically creates a thumbnail, for viewing in the file manager. It stores those thumbnails in a hidden directory in your user account at the location
Over time, the number of thumbnails would increase dramatically. Moreover, the thumbnail cache will eventually contain many superfluous thumbnails of pictures that don’t exist anymore.
You can check the size of the thumbnail cache with the command below:
For my system, the thumbnail cache is over 300 Mb in size.
» data-medium-file=»https://itsfoss.com/wp-content/uploads/2017/06/clean-up-space-ubuntu-linux-3-300×51.png» data-large-file=»https://itsfoss.com/wp-content/uploads/2017/06/clean-up-space-ubuntu-linux-3.png» width=»732″ height=»125″ src=»https://itsfoss.com/wp-content/uploads/2017/06/clean-up-space-ubuntu-linux-3.png» alt=»Clean thumbnail cache to free up space in Ubuntu» data-lazy-srcset=»https://itsfoss.com/wp-content/uploads/2017/06/clean-up-space-ubuntu-linux-3.png 732w, https://itsfoss.com/wp-content/uploads/2017/06/clean-up-space-ubuntu-linux-3-300×51.png 300w» data-lazy-sizes=»(max-width: 732px) 100vw, 732px» data-lazy-src=»https://itsfoss.com/wp-content/uploads/2017/06/clean-up-space-ubuntu-linux-3.png?is-pending-load=1″ srcset=»data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7″> size of thumbnail cache can be a sore thumb
So it’s a good practice to clear the thumbnail cache every few months or so. The quickest way is to use the terminal (please copy-paste the commands to avoid mistakes):
7. Find and remove duplicate files
Sometimes you may have duplicate files in different places in your system. Getting rid of the duplicates will certainly free up some space and clean your Ubuntu system.
You can use a GUI tool like FSlint or a command line tool like FDUPES for this task. I recommend reading this article to see how to use these tools to remove duplicate files.
» data-medium-file=»https://itsfoss.com/wp-content/uploads/2017/08/fdupes-tutorials-300×145.jpg» data-large-file=»https://itsfoss.com/wp-content/uploads/2017/08/fdupes-tutorials-800×387.jpg» width=»800″ height=»387″ src=»https://itsfoss.com/wp-content/uploads/2017/08/fdupes-tutorials-800×387.jpg» alt=»fdupes-tutorials» data-lazy-srcset=»https://itsfoss.com/wp-content/uploads/2017/08/fdupes-tutorials-800×387.jpg 800w, https://itsfoss.com/wp-content/uploads/2017/08/fdupes-tutorials-300×145.jpg 300w, https://itsfoss.com/wp-content/uploads/2017/08/fdupes-tutorials-768×372.jpg 768w, https://itsfoss.com/wp-content/uploads/2017/08/fdupes-tutorials.jpg 816w» data-lazy-sizes=»(max-width: 800px) 100vw, 800px» data-lazy-src=»https://itsfoss.com/wp-content/uploads/2017/08/fdupes-tutorials-800×387.jpg?is-pending-load=1″ srcset=»data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7″> FDUPES: finding and removing duplicate files
Remove old Linux kernels that were manually installed [For Experts]
The command discussed in point 1 removes the old Linux kernel. But it won’t work if you manually installed the kernel in Ubuntu. But removing old, unused Linux kernels will still save you plenty of space.
So, if you manually installed a Linux kernel, perhaps you can manually uninstall it as well.
List all installed Linux kernels first:
Removing the old kernels is the same as removing any other package. I’m using shell expansion for the version numbers to save typing. It will prompt you with a list of packages that will be removed, so you can double check the list before continuing.
Note: Replace VERSION with the version of the kernel you want to remove.
My recommendation is to keep at least two or preferably three kernels including the latest. This way, you will have at least one/two other kernels to boot with, if for whatever reason the latest kernel you are unable to boot with.
Remove orphaned packages [For Experts]
This step is best avoided if you are a beginner. I am not a fan of this method and I advise you to avoid it.
First, let’s see what is an orphaned package in Ubuntu.
Suppose you installed a package ‘myprogram’. But this package has a dependency on the library ‘mylib’. This lib will be usually installed automatically with ‘myprogram’. When you delete ‘myprogram’, mylib might still remain in the system. Thus mylib, in this case, becomes an orphaned package.
Now, the command listed in point 1 removes such orphaned packages. But imagine the case where you had manually installed mylib before installing myprogram. The command ‘apt autoremove’ might not remove the orphaned package in this case. And hence you’ll have to manually delete it.
You’ll have to find all the orphaned packages first and then remove them. Thankfully, we have a GUI tool to do that: gtkorphan, a graphical frontend for deborphan.
Install gtkorphan via the terminal:
And to remove orphaned packages, search for Removed Orphaned Package tool and run it to find all the orphaned packages in your system:
» data-medium-file=»https://itsfoss.com/wp-content/uploads/2017/06/clean-up-space-ubuntu-linux-4-300×281.png» data-large-file=»https://itsfoss.com/wp-content/uploads/2017/06/clean-up-space-ubuntu-linux-4.png» width=»564″ height=»528″ src=»https://itsfoss.com/wp-content/uploads/2017/06/clean-up-space-ubuntu-linux-4.png» alt=»Remove orphaned packages in Ubuntu» data-lazy-srcset=»https://itsfoss.com/wp-content/uploads/2017/06/clean-up-space-ubuntu-linux-4.png 564w, https://itsfoss.com/wp-content/uploads/2017/06/clean-up-space-ubuntu-linux-4-300×281.png 300w» data-lazy-sizes=»(max-width: 564px) 100vw, 564px» data-lazy-src=»https://itsfoss.com/wp-content/uploads/2017/06/clean-up-space-ubuntu-linux-4.png?is-pending-load=1″ srcset=»data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7″> Find and remove orphaned packages in Ubuntu
Honestly, I won’t go for this option unless you really need every Mb of free space.
Bonus Tip: Using GUI tools to free space in Ubuntu
We saw a number of command-line options to make space in the Linux system but I understand if you don’t want to use the commands.
Remembering all the commands or using them all one by one may not be convenient for you. And this is why we have a number of GUI tools that will help you do that in a few clicks with an easy-to-use interface.
Stacer is one such tool that you could use. You can read this article to know how to use Stacer in Ubuntu.
You can check out more tools to clean up Ubuntu and make some free space easily.
Wrapping up
So, you saw a number of ways to clean up the Ubuntu system. Personally, I use apt-get autoremove more often than any other commands here. Regularly using this command keeps the system free from unnecessary files.
I hope this article helped you to make free space in Ubuntu, Linux Mint, and other such distributions. Do let me know if this worked for you or if you have some other tips to share.
Creator of It’s FOSS. An ardent Linux user & open source promoter. Huge fan of classic detective mysteries ranging from Agatha Christie and Sherlock Holmes to Detective Columbo & Ellery Queen. Also a movie buff with a soft corner for film noir.
8 Ways to Maintain a Clean, Lean Ubuntu Machine
Regardless of the operating system you are using sometimes it will become bloated with plenty of useless files lying around. To make it worse, you have barely enough storage space left in your hard disk, even though you just upgraded it not long ago. Therefore, it is necessary to do some maintenance on your PC once in a while and clean up unnecessary files that are chunking up large storage space in your hard disk.
Here are eight ways Ubuntu user can clean up their Ubuntu.
1. Analyze your disk usage
The first thing you need to do is find out which files are consuming th bulk of the storage space in your hard disk. Launch “Disk Usage Analyzer” from your Applications list (it is located in the “Utilities” folder), and click on your hard disk 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:
2. Clear duplicate files and broken symlinks
Over time you could have a dozen copies of the same file lying in different corners of your system. The best idea 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.
1. Install FSlint with the following command (in your terminal):
2. Launch “FSlint Janitor” from the Applications list. 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 to help recover 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 dependent files that you have absolutely no use for. The following are some useful commands to get rid of any partial package and remove any unused dependencies:
Essential Guide: 5 Simple Ways To Free Up Space on Ubuntu
Let’s say you need to free up space on Ubuntu — how do you go about it?
Unlike Windows, which comes with built-in defrag and disk clean-up tools, Ubuntu doesn’t make it immediately obvious how you go about trying to free up space.
Below, we show you 5 super simple (and in some cases blindingly obvious yet easily forgotten) steps you can take to get back GBs, materialise MBs, and clean out the KB cruft!
Next time you need more space — and heck: even if you don’t — here are 5 simple ways to free up disk space on Ubuntu.
1. Clean the APT Cache (And Do It Regularly)
It sounds so obvious yet chances are you haven’t done this for a while.
By default Ubuntu keeps every update it downloads and installs in a cache on your disk, just in case you need it again.
This is useful if you regularly add and remove apps, find yourself needing to reconfigure/reinstall a specific package, or simply have a poor connection.
But the flip side is that the apt package cache can quickly swell to several hundred MBs. This command tells you how big your apt cache is:
To clean the apt cache on Ubuntu simply run the following command.
The apt clean command removes ALL packages kept in the apt cache, regardless of age or need. If you’re on a slow, capped or intermittent connection you may want to consider skipping this step.
2. Remove Old Kernels (If No Longer Required)
Now, admittedly, this step is one you want to approach with caution.
Having a choice of kernels to boot up is, honestly, quite handy, especially if you notice something has gone awry while using the latest one.
Unless you’re in the throes of constant hardware woes there’s little need to hoard kernels.
It’s easy to remove old kernels in Ubuntu. You can do it from the command line using the following command:
Note that this command will only remove kernels that a) are no longer needed and b) were installed from the Ubuntu archive through system updates. If you install kernels manually or using a third-party PPA you’ll need to roll up your sleeves and remove those manually.
3. Uninstall Apps & Games You Never Use (And Be Honest!)
Chances are you have a number of apps installed that you never use. Maybe you installed them on the back of an awesome review, out of nosiness, or to tackle a specific task.
Whatever the excuse, if you no longer need an app, and it’s taking up space, don’t be afraid to uninstall it.
Typical apps you may wish to expunge include web browsers (are you ever going to use Opera, Epiphany, Midori and Min?), music players (heck knows there’s enough of ’em) and games that sounded good in the Steam Store blurb but were as much fun as a Windows 10 update combo!
And everyone has LibreOffce Draw knocking about doing nothing! 😅
Don’t lie to yourself about might-needs and could-dos, either. The beauty of most software is that it’s not going away anytime soon. This is never truer than on Linux, where apps remain an apt install command away.
To remove apps from the command line run:
To remove excess packages and dependencies that are no longer required (because you’ve uninstalled other packages or newer versions have replaced them) run the following command:
4. Use A System Cleaner like BleachBit
Writing a “to-do” list on system cleaning would end up 10x longer if we listed every app, cache, log and system process hiding in every nook and cranny of your OS.
BleachBit saves us from doing that.
It’s like CCleaner for Linux; a byte scouring beast. The app can find and clean pretty much every fluff file there is and, as a result, should only ever be used with caution.
BleachBut can wipe the caches of more than 70 popular desktop applications (including most web browsers); hoover up old file, browser and bash histories; and makes light work of those crash logs you’ll never get around to reading.
No surprise that we recommend installing it as one of our top things to do after installing Ubuntu.
You can install BleachBit on Ubuntu 16.04 LTS (and above) straight from Ubuntu Software.
Run the app as root for maximum cleaning power. Check the boxes beside the things you’d like to clean. Click Preview to see an estimate of how much space they currently take up, and click Clean to remove them.
5. Stay up to date (seriously, do it!)
The most obvious step on this list is also the one few people would think to recommend. See, unlike Windows, where every new update adds more overhead and bloat, package updates on Linux often free space rather than use it.
So next time you put off that 156MB librandom-package102 update cos you’re running low on space, maybe think again!
Summary
That just about covers it. If you only remember two steps from this list make it the first and last.
Now go forth and free space!
Let us know how much space you manage to claw back or share your own top space-saving tips in the comments!
Home » How To » 5 Simple Ways To Free Up Space on Ubuntu