4 Ways to Free Up Disk Space on Linux

Optimizing Disk Space on Linux Systems
Linux-based operating systems, while powerful, can sometimes consume more disk space than necessary.
A common example is the APT package manager, which retains downloaded package files even post-installation.
This practice can lead to wasted storage, particularly if frequent uninstalls and reinstalls aren't anticipated.
Similarities to Other Operating Systems
Strategies for reclaiming disk space on Linux share common ground with those for Windows and macOS.
We have previously detailed methods for freeing up disk space on both Windows and Mac platforms.
These techniques often involve the removal of temporary files, a thorough analysis of disk utilization, and identification of applications with substantial storage footprints.
Key Disk Space Saving Techniques
- Temporary File Removal: Regularly deleting temporary files can free up significant space.
- Disk Usage Analysis: Tools can help pinpoint which files and folders are consuming the most storage.
- Application Space Audit: Identifying applications that utilize excessive disk space allows for informed decisions about their continued use.
Effective disk space management is crucial for maintaining optimal system performance across all operating systems, including Linux.
Removing Temporary Files
Related: 7 Tips to Maximize BleachBit, a Linux Alternative to CCleaner
BleachBit functions as a CCleaner equivalent for Linux systems. It systematically examines your computer for superfluous temporary files and then proceeds to delete them, thereby reclaiming valuable disk space. This encompasses items like cached data, browsing histories, and various other transient files.
Installation of BleachBit is readily achievable through the Ubuntu Software Center.
It’s important to recognize that the tool’s ability to eliminate APT packages and perform other system-level cleanup tasks is contingent upon being executed with elevated privileges. To launch BleachBit as root, utilize the sudo bleachbit command within a terminal. (The previously suggested gksu command is no longer available in Ubuntu.)
A significant advantage of BleachBit lies in its automation of procedures typically reserved for seasoned Linux users. Specifically, it executes the autoclean, autoremove, and clean commands associated with APT.
These commands serve to uninstall packages that are no longer required and to discard cached package files that have already been installed. Retaining these downloaded package files is unnecessary, akin to Windows preserving software installers even after program installation.
Should reinstallation become necessary, APT can readily download them again.

Related: Methods for Reclaiming Disk Space on macOS
Understanding Your Disk Space Consumption
Related: What Is a Linux Distro, and How Are They Different from One Another?
Ubuntu provides a utility designed to scan your file system. It then presents a visual representation of disk space usage by directories and individual files.
This functionality proves invaluable when attempting to reclaim storage. Perhaps a forgotten virtual machine image or another sizable file is hidden within your home directory? This tool will locate it and clearly indicate its substantial space allocation.
The application is pre-installed on Ubuntu systems. Simply launch the Disk Usage Analyzer to access its features.
If you are utilizing a different Linux distribution, it may be included by default as part of the GNOME desktop environment. If not, search for the Baobab package to install it.

Identifying Applications Consuming Significant Disk Space
Related: Understanding Software Installation and Package Managers in Linux
The applications you have installed, existing as packages, contribute to the overall disk space usage on your system. A large number of installed applications can collectively occupy a considerable amount of storage. To ascertain the disk space utilized by these packages, we suggest utilizing the Synaptic package manager.
While formerly included in the default Ubuntu installation, Synaptic was later removed to prioritize simpler tools. Installation can be achieved by opening the Ubuntu Software Center and searching for Synaptic.
Users of other Debian-based distributions will likely also have access to Synaptic. However, if your distribution isn't based on Debian, a different package management utility will likely be necessary.
Viewing Package Sizes in Synaptic
To identify which packages are the largest, within Synaptic, navigate to Status > Installed. This will display a comprehensive list of all currently installed packages.
Subsequently, clicking the Size column will sort the packages by their respective sizes. (Should the Size column not be visible, access Settings > Preferences and verify its activation on the Columns and Fonts tab. It can also be repositioned to the top of the list for immediate visibility.)
It’s important to note that a large package size doesn't automatically warrant uninstallation. Certain packages are vital for core system operations, such as the Linux kernel.
However, as illustrated, applications like LibreOffice, Firefox, and Thunderbird can collectively consume a substantial amount of disk space. If storage is limited and these applications are infrequently used, their removal could free up valuable space. Reinstallation is always possible through the package manager at a later time.

Managing Older Kernels
Related: Understanding the Linux Kernel and Its Functionality
Ubuntu retains previous Linux kernels even after new versions are installed. These kernels are accessible through the boot loader menu during system startup. This functionality provides a fallback option should a newer kernel introduce instability, allowing a return to a working state. However, if the current kernel operates without issue, these older versions simply consume disk space.
Crucially, before deleting any kernel-related files, confirm a reboot has occurred following the latest kernel update. Ensure you are not currently running an older kernel version. While Ubuntu defaults to the newest kernel upon startup, a recent update without a reboot may still leave the system utilizing an older version.
Removing Kernels with Synaptic
Old Linux kernels can be easily removed using the Synaptic package manager. Initiate a search within Synaptic by pressing Ctrl+F. Configure the search to focus solely on the 'Name' field and enter 'linux-'.
Subsequently, sort the results by installed packages. The relevant packages will then appear at the top of the list. This allows for easy identification of kernels available for removal.

Observe that multiple versions exist for packages like linux-image-extra, linux-headers, and linux-. Older versions of all these associated packages can be removed. Select the outdated versions, right-click, and mark them for removal. Finally, apply the changes to reclaim disk space.
It is vital to only remove older kernel versions. The most recent version must remain intact to ensure system bootability. For instance, retaining the files for version 3.11.0-18 while removing those for 3.11.0-12 and 3.11.0-15 is a safe practice.

For Linux servers, additional space can potentially be freed by purging or reducing the size of extensive log files. If an application generates unnecessarily large log files, its configuration can be adjusted to log only critical events, thus conserving disk space.
Image courtesy of Jason Mann on Flickr