5 Best Ways to Free up Hard Disk Space in Ubuntu

Listed are top five best and safer ways to clean and free up hard disk space in Ubuntu

Hard disk space is something which is never enough. Every now and then there comes a time when you may want to free up hard disk space. Although you can be little liberal when you have several terabytes of conventional hard disk, same is not the case when you have a solid state hard disk. Higher capacity SSDs are still expensive. That’s one of the reasons why even a high range laptop still ships with 256 to 500GB SSD.

Like any other OS, if not maintained properly, Ubuntu too consumes a considerable amount of hard disk over a period of time. Hard disk space can get easily filled up with cached package files, old kernels, and not used apps. Let’s take a look at various ways on how to clean up your Ubuntu installation, and regain the lost hard disk space.

Free Up Hard disk space in Ubuntu

1. Delete Cached Package Files

Every time you install some apps or even system updates, the package manager downloads and then caches them before installing them, just in case they need to be installed again. If the installation was successful, Ubuntu doesn’t go and delete the left cache – it’s just leftover garbage. It’s recommended that you clean up these packages to gain hard disk space, improve the performance of your PC, and speed up boot times.

Want proof? Check out the used space in /var/cache/apt/archives folder. Simply run the following command from the Terminal to clean up those files.

sudo apt-get -s clean

This command will clean up following directories. It is completely safe to do so:

  • /var/cache/apt/archives/partial/*,
  • /var/lib/apt/lists/partial/*
  • /var/cache/apt/pkgcache.bin
  • /var/cache/apt/srcpkgcache.bin

2. Delete Old Linux Kernels

Another huge junk of files that will be left over in your Ubuntu PC is the bunch of old Linux kernels. Ubuntu and almost all other Linux distros retain the old kernels after updating to new kernels so that you can boot with the older kernel in case of a problematic kernel update. I would recommend to keep at least a couple of old kernels just to be safe and delete all others.

In order to do that, you first need to know the installed Linux kernel versions on your computer. Use this command:

sudo dpkg --list 'linux-image*'

Then use ‘remove’ command to delete the older versions. Replace xxxxx with the Linux version you want to delete.

sudo apt-get remove linux-image-xxxxx

Alternatively, a simpler way to clean old kernels is to use ‘autoremove’ command. Once your PC is stable with the current Linux Kernel, you can get rid of all older ones using the following command in the Terminal.

sudo apt-get autoremove --purge

3. Use Stacer  –  GUI based System Optimizer

For those who feel Terminal usage is not their cup of coffee, I highly recommend beautiful application ‘Stacer’.

Stacer Dashboard
Stacer Dashboard

Stacer is a feature-rich free system optimizer for Linux. It has several system tools. One among them is the ability to clean up obsolete files. Refer our detailed article on Stacer and how to use install and use it.

4. BleachBit – GUI based System Cleaner

BleachBit is yet another GUI based system cleaner for Ubuntu. It offers similar functionality to the items #1 and #2 in this article. It is a free utility available in the Ubuntu Software. Alternatively, you can use below commands to install it.

sudo apt update
sudo apt install bleachbit

BleachBit
BleachBit – Free up Hard disk space

BleachBit includes a good list of cleaners such as removal of APT packages, thumbs.db, cache, browser cache & cookies, log files, backup files, etc..

5. System Update!

Unlike Windows OS which loves accumulating all the old junk files, Linux on other hand is self-cleaning when you keep it updated from time to time. Typically, version upgrades bring a lot of new features as well as remove the old junk too, thus helping you clean up your Ubuntu system. Now, that’s one more reason to keep your system up to date!

Kiran Kumar
Hi there! I'm Kiran Kumar, founder of FOSSLinux.com. I'm an avid Linux lover and enjoy hands-on with new promising distros. Currently, I'm using Ubuntu as a daily driver and run several other distros such as Fedora, Solus, Manjaro, Debian, and some new ones on my test PC and virtual machines. I have a day job as an Engineer, and this website is one of my favorite past time activities, especially during Winter ;). When I'm not writing for FOSSLinux, I'm seen biking and hiking on scenic trails. I hope you enjoy using this website as much as I do writing for it. Feedback from readers is something that inspires me to do more and spread Linux love!. If you find a time, drop me an email or feedback from the 'Contact' page. Or simply leave a comment below if you found this article useful. Have a good day!

3 COMMENTS

  1. EDIT: apt-get was still running. It is actually 9 GB, all old kernels from #2 (while #1 gave ca. 400 MB spare space). This allows me to keep my old 32 GB system SSD. Thx again!

LEAVE A REPLY

Please enter your comment!
Please enter your name here

STAY CONNECTED

23,278FansLike
384FollowersFollow
16SubscribersSubscribe

LATEST ARTICLES

MUST READ

Buyers who wish to go for a machine that is based on Linux often show interest in Chromebooks due to the form factor and extended battery life capabilities. Although ChromeOS power these machines, users can still miss out on a more genuine Linux experience. For those who happen to agree, the new Lemur Pro by System76 might get some heads turning.
Linux is growing faster than ever. As per the latest report, there is a drop in the Windows 10 market share for the first time, and Linux's market share has improved to 2.87% this month. Most of the features in the list were rolled out in the Pop OS 20.04. Let's a detailed look into the new features, how to upgrade, and a ride through video.

Manjaro ‘Gellivara’ XFCE Edition (17.0.5) in 10 Screenshots

Want to take a quick virtual tour Manjaro XFCE edition instead of downloading GBs worth of ISO image and then making a Live USB of it? We will make it easy for you. Here are a series of screenshots of the important aspects of Manjaro Linux in XFCE edition. This is a light-weight edition, and aims to be fast and low on system resources. You will be amazed on how it is still visually appealing and user friendly.

6 Best Linux Distributions for Beginners

Making the shift to Linux is not as complicated as some people make it out to be. There is a variety of Linux distributions available that cater to the needs of people who are planning on making the jump to Linux from any other operating system.

Top 10 Reasons to use Xfce as your Desktop Environment

There are many choices for desktop environments for Linux based operating systems. Mainly, you can install any DE of your choice on most of the Linux based distributions, even if they are not offered as a package officially. In our recent articles, we discussed the best of KDE and Cinnamon. In this article, we wish to present to you the top reasons why you should consider Xfce as your desktop environment.

How to make Ubuntu look like Windows XP

If you are in a nostalgic mood and would like to make your Ubuntu look like Windows XP, you just landed in the right place. In this article, we will show you how you can make Ubuntu look like Windows XP by applying the GTK+ theme. Our Ubuntu distribution of choice is Ubuntu 20.04 LTS.