How to clean up disk space on Linux

Last updated on September 24, 2020 by Dan Nanni

If you have an aged Linux system, chances are that you have a lot of disk space wasted due to things like application-specific caches (e.g., browser caches), system caches (e.g., apt cache), unnecessary locale files or other temporary files. With so many different ways files are generated, it is hard to track down the wasted disk usage, and free up disk space appropriately.

BleachBit is an open-source disk space cleaner software, available on Linux and Windows platforms. Besides cleaning up disk space, BleachBit can also shred files securely, and wipe out unallocated disk space for your privacy.

In this tutorial, I will describe how to clean up disk space on Linux by using BleachBit.

BleachBit Features

BleachBit has a number of features that make it an essential tool for disk cleaning and privacy protection:

Install BleachBit on Linux

BleachBit's official website offers installation packages for popular Linux distributions. Download an appropriate package for your system, and install it along with its dependencies as follows. BleachBit requires Python >= 2.5 and <=2.7, and PyGTK 2.14 or later.

Install BleachBit on Ubuntu

$ sudo apt-get install python-gtk2 python-simplejson
$ sudo dpkg -i bleachbit_0.9.6_all_ubuntuXXXX.deb

Install BleachBit on Debian:

$ sudo apt-get install python-gtk2 python-simplejson
$ sudo dpkg -i bleachbit_0.9.6_all_debianX.deb

Install BleachBit on Fedora:

$ sudo yum install pygtk2 python-simplejson
$ sudo rpm -ivh bleachbit-0.9.6-1.1.fcXX.noarch.rpm

Install BleachBit on CentOS 6:

$ sudo yum install pygtk2 python-simplejson
$ sudo rpm -ivh bleachbit-0.9.6-1.1.centosCentOS-6.noarch.rpm

Configure BleachBit

To launch BleachBit, simply run:

$ sudo bleachbit

The first time you run BleachBit, you will be asked to configure the preferences of BleachBit. You can also enter the preferences settings any time, by going to EditPreferences menu.

In the preference settings, you can control the following options.

Clean Up Disk Space with BleachBit GUI

The main window of BleachBit shows a list of available cleaners in the left panel. The complete list of cleaners may vary depending on your Linux system setup, since BleachBit automatically hides irrelevant cleaners. If you click on any cleaner, you will see corresponding cleaning items.

You can selectively enable a particular cleaner and particular cleaning items underneath it.

Once you are done with cleaner selection, click on Preview button at the top bar. You will see a list of actions to be performed during disk cleaning, and check how much disk space will be recovered once cleaning is done.

Clean Up Disk Space from the Command Line

One nice feature of BleachBit is the fact that you can run BleachBit in command line mode. Thus you can easily schedule a cron job to clean your Linux system periodically.

To see a list of available cleaning items:

$ bleachbit --list
info: starting BleachBit version 0.9.6
adobe_reader.cache
adobe_reader.mru
adobe_reader.tmp
amsn.cache
amsn.chat_logs
amule.logs
amule.tmp
apt.autoclean
apt.autoremove
apt.clean
. . .

To preview the result (i.e., individual deletions and final disk space savings) of a particular cleaner:

$ bleachbit --preview apt.clean apt.autoremove
info: starting BleachBit version 0.9.6
debug: clean_operation('apt'), options = '['clean']'
Delete 1.1MB /var/cache/apt/archives/keepassx_0.4.3-1ubuntu3_amd64.deb
Delete 81.9kB /var/cache/apt/archives/libaudiofile1_0.3.4-1_amd64.deb
Delete 1.5MB /var/cache/apt/archives/tor-geoipdb_0.2.3.25-1~quantal+1_all.deb
Delete 217.1kB /var/cache/apt/archives/duplicity_0.6.19-0ubuntu2.2_amd64.deb
. . .
Disk space to be recovered: 107.9MB
Files to be deleted: 56

To conduct actual disk cleaning job:

$ sudo bleachbit --clean apt.clean apt.autoremove

To conduct actual disk cleaning job and overwrite contents of deleted files:

$ sudo bleachbit --overwrite --clean apt.clean apt.autoremove

Support Xmodulo

This website is made possible by minimal ads and your gracious donation via PayPal or credit card

Please note that this article is published by Xmodulo.com under a Creative Commons Attribution-ShareAlike 3.0 Unported License. If you would like to use the whole or any part of this article, you need to cite this web page at Xmodulo.com as the original source.

Xmodulo © 2021 ‒ AboutWrite for UsFeed ‒ Powered by DigitalOcean