Are you running out of space on your Linux system? Here are several ways to clean your system to free up space in Ubuntu and other Linux distributions based on Debian as Linux Mint.
Over time, the hard drive of any operating system can be disorganized as programs are added and removed. If you have 1 TB (a Terabyte) of storage capacity, you may not worry about cleaning up Linux Ubuntu to create disk space. But if your hard disk has limited space, as I have a 128 GB SSD laptop, releasing disc space becomes a necessity.
First, let’s find out how to check the remaining free space in Linux Ubuntu and Linux Mint.
Check the disk space on Linux Ubuntu and Mint
It is always a good idea first to check the free disk space on Linux.
This is quite easy at Ubuntu and Mint. Can be done using a visual or terminal tool.
Check disk space on Linux using the desktop
To check disk space on Linux using the desktop just use the Disk Usage Analyzer tool - Disc Use Analyzer. Search the menu and run the tool.
You must see the used disk space and the remaining free space here:
Once you know the state of free space on your disk, it’s time to clean your system and create more free space for your Linux Mint or Ubuntu operating system.
Check disk space on Linux using the terminal
The simplest way to find free disk space on Linux, by terminal, is to use the
df command. The
df means disk free and obviously shows the free and available disk space on Linux systems.
df command with the
-h option, shows the disk space in the format readable by humans (MB and GB).
Here is an example of the command output
How to clean, to free disc space on Linux Ubuntu and Mint
There are several ways to clean the disk space on Linux Ubuntu and other Debian based systems. Then I present some tips on how to do the Bash command line and also some Gui options.
If you are a beginner, avoid those marked as “advanced”.
I am using Linux Mint 20.03 while I write this tutorial, but you can use the same steps for older versions like Ubuntu 18.04 and other Ubuntu, Linux Mint versions, and other Debian based Linux distributions.
Delete APT packages that are no longer needed [*Recommended]
This topic show how to clean disc space on Linux Ubuntu and Mint by deleting APT packages.
If you have read the APT-Get command guide, you may have found the
apt-get 'autoremove' apt-get option.
This option removes Libs and packages that were automatically installed to satisfy the requisites of a package installed. If this original package is removed, these automatically installed packages will be useless in the system.
This command also removes the old Linux kernels that were automatically installed in the system update.
First, you can check the size being used by the apt cache using the
sudo du -sh /var/cache/apt
After checking the size used bt apt cache, run the
autoremove, it is a basic command that you can run from time to time to release some space on your Ubuntu and Mint system:
sudo apt-get autoremove
You can also remove only outdated packages, such as those replaced by a recent update, making them completely unnecessary.
Autoclean for this:
sudo apt-get autoclean
Or you can remove the entire cache from APT packets, this option will release more disk space from your Linux Ubuntu and Linux Mint operating system:
sudo apt-get clean
Uninstall applications that are no longer necessary [* recommended]
We all install games or applications to know, test, or use at a given time, which are no longer necessary over time.
To check the installed applications, open the Application manager or Software Manager, and look for the “Show installed applications” menu option.
The manager will list all installed applications, you can click those that are no longer needed and then remove them:
You can also remove applications using the command line with
sudo apt-get remove package-1 package-2
Automatically remove old kernels on Linux Mint
From Linux Mint 19.2, you can define that the operating system automatically removes the obsolete versions and dependencies of the Linux kernel.
The Update Manager app comes with the disabled option for this action.
Follow the steps to connect this option:
- Click the menu button on the panel to open the application menu.
- Go to System -> Update Manager
- On the manager screen, open the edit menu and choose Preferences
- On the preference screen click on the tab Automation
- In the Automation tab Turn the option Remove kernels and obsolete dependencies, type your password when requested
At approximately a weekly frequency, the update manager checks and removes obsolete kernels.
There are several options and strategies to keep the space on disk and, consequently, the performance of the Linux Ubuntu and Mint operating system.
If you use any other in your routine, please share with us in the comments of this article.
- It’s Foss - Free up space in linux Ubuntu
- Automatic remove old kernels on Linux Mint