SEARCH

How-To Geek

4 Ways to Free Up Disk Space on Linux

ubuntu-linux-laptop

Linux systems aren’t as light on disk space as they could be. For example, the APT package manager keeps package files around even after you install them — a waste of space unless you plan on uninstalling and reinstalling them.

We’ve also covered freeing up disk space on Windows and freeing up disk space on a Mac. Many of the tips are similar — removing temporary files, analyzing your disk usage, and seeing which installed applications use the most space.

Delete Temporary Files

RELATED ARTICLE
7 Tips to Get the Most Out of BleachBit, a “CCleaner for Linux”
Like CCleaner on Windows, BleachBit frees space by deleting unimportant files and helps maintain your privacy by deleting sensitive data.... [Read Article]

BleachBit is basically a CCleaner for Linux. It will scan your computer for unnecessary temporary files and automatically remove them to free up space. This includes caches, browser histories, and other temporary files. You can install BleachBit from the Ubuntu Software Center.

Note that this tool won’t be able to remove APT packages and other system-wide stuff unless you open it with root privileges. Open a terminal and run the sudo bleachbit command to open it as root. (The gksu command, which we would have recommended previously, has been removed from Ubuntu.)

One of the nicest things about BleachBit is that it automates some things that only experienced Linux users would normally think to do. For example, it runs the autoclean, autoremove, and clean commands for APT — this uninstalls packages you no longer need and removes cached package files that are already installed. You don’t need these downloaded package files — it’s sort of like if Windows kept all the software installers around even after you installed the associated program. In the unlikely even you need to reinstall them, APT can download them again.

bleachbit-is-ccleaner-for-linux

RELATED ARTICLES
7 Ways To Free Up Hard Disk Space On Windows
Hard drives are getting larger and larger, but somehow they always seem to fill up. This is even more true... [Read Article]
5 Ways To Free Up Disk Space on a Mac
It’s 2014, shouldn’t we stop worrying about disk space? Nope, not at all! A modern MacBook might have a solid-state drive with... [Read Article]

Analyze Your Disk Usage

RELATED ARTICLE
HTG Explains: What’s a Linux Distro and How Are They Different?
If you’ve heard anything at all about Linux, you’ve probably heard of Linux distributions – often shortened to “Linux distros.”... [Read Article]

Ubuntu includes a tool that will scan your file system and show a graphical overview of which directories and files are using the most space. This can be a big help when you’re trying to free up space — do you have an old virtual machine or another large file buried somewhere in your home directory? This tool will find it and make it very obvious that it’s taking up a large amount of space.

This tool is installed by default — launch the Disk Usage Analyzer tool to open it. If you’re using another Linux distribution, it may already be installed by default, as it’s part of GNOME — if not, look for the Baobab package.

analyze-disk-usage-on-linux

Find Which Appliations Are Using the Most Space

RELATED ARTICLE
HTG Explains: How Software Installation & Package Managers Work On Linux
Installing software on Linux involves package managers and software repositories, not downloading and running .exe files from websites like on... [Read Article]

Your installed applications — in the form of packages — are taking up space on your hard drive, too. If you have quite a few applications installed, they may be taking up quite a bit of space. To determine how much space packages are taking up, we recommend the Synaptic package manager. It was previously a part of Ubuntu, but was removed from the default install to make room for simpler utilities. To install it, open the Ubuntu Software Center and search for Synaptic.

If you use another .deb-based distribution, you’ll probably also have access to Synaptic. If you use a distribution not based on Debian, you’ll probably have to use a different package management utility for this.

To view which packages are using the most space, select Status > Installed in Synaptic to see a list of all your installed packages. Next, click the Size column to view a list of your installed packages by size. (If you don’t see the Size column, click Settings > Preferences and ensure the Size column is enabled on the Columns and Fonts tab. You can also move it to the top of the list and it will appear on the left.)

Of course, just because a package is using up a lot of space doesn’t mean you should uninstall it. Some packages are crucial for system functioning, like the Linux kernel. However, below we an see that LibreOffice, Firefox, and Thunderbird are using up a decent chunk of space between them — if we were really short on space and we never used these applications, we could uninstall them to free up space. We could always reinstall them from the package manager in the future.

synaptic-sort-installed-packages-by-size

Remove Old Kernels

RELATED ARTICLE
What is the Linux Kernel and What Does It Do?
With over 13 million lines of code, the Linux kernel is one of the largest open source projects in the world, but what is a kernel and what is it used for? [Read Article]

Ubuntu keeps old Linux kernels around even after it installs new versions. You can choose to boot into these old kernels from the boot loader menu that appears when you boot your computer. This is useful if a new Linux kernel breaks something and you have to go back to an old kernel so your system will work properly — but if the latest kernel is working fine, all these old kernels do is take up space.

Important: Before removing any kernel files, ensure that you’ve rebooted after installing the latest kernel update and aren’t currently using an old kernel. Ubuntu will automatically boot into the latest kernel when you start it, but you may still be using an old kernel if you haven’t rebooted in awhile and there was a recent kernel update.

It’s easy to remove old Linux kernels using the Synaptic package manager utility. Press Ctrl+F in Synaptic, tell the search feature to search only the Name field, and search for linux- — yes, with the dash. Sort by installed packages and you’ll see the appropriate packages appear at the top of the list.

search-for-installed-linux-kernels-in-synaptic-on-ubuntu

Note that we have several different versions for the linux-image-extra, linux-headers, and linux- packages. We can remove old versions of all of these packages — each kernel has multiple different packages associated with it. Just select the old versions, right-click, and mark them for removal. Apply your changes afterwards to free up some space.

Remember — only remove the old versions of the kernel files! Leave the most recent versions alone or your system will become unbootable. For example, in the image below, we want to leave the 3.11.0-18 files alone while removing the 3.11.0-12 and 3.11.0-15 files. According to Synaptic, removing these two kernels and their associated files freed up over 500 MB of space.

remove-old-linux-kernels-on-ubuntu


If you operate a Linux server, you may also be able to free up some space by purging or shrinking large log files. If an application is generating large log files you don’t need, you may be able to change its options so that it logs only the most important events to the files, saving disk space.

Image Credit: Jason Mann on Flickr

Chris Hoffman is a technology writer and all-around computer geek. He's as at home using the Linux terminal as he is digging into the Windows registry. Connect with him on Google+.

  • Published 03/21/14

Enter Your Email Here to Get Access for Free:

Go check your email!