Bleach Bit Safe Settings

I want to clean my 18.04 installation. Under 16.04 I typically used Ubuntu Tweak Janitor to clean my system. I once tried Bleach Bit but it left my system unbootable. So I am hesitant to try again. Since Ubuntu Tweak does not install under 18.04, what settings under Bleach Bit do I need to be careful with? Also, is the Deep Scan safe? I will also want to clean old kernels. Any recommendations? I was thinking of sudo purge-old-kernels --keep 2 -qy.

I check the kernel I have and keep (uname -r),
then get a list of the installed kernels with dpkg -l | grep linux-image
then I purge one by one with sudo dpkg purge linux-image-x.x.x

there are scripts out there that will remove old kernels but 2, but I’m old school.

I don’t use and neither recommend a cleaning software for Linux.

First of all, software under Linux aren’t bloated at all, unlike Windows.

Then all temporary files get erased when you power off your machine.

And speaking of older kernels, after a kernel update, your OS will report to you that the older kernel(s) and related parts aren’t required anymore. You can easily remove them using sudo apt-get --purge autoremove(--purge is for cleaning the configuration files too).

You can clean most useless packages files with sudo apt-get autoclean.

From time to time, you can run sudo apt-get clean which cleans up all local repository packages that autoclean doesn’t.

Assuming one doesn’t want to run a bunch of commands every time, there’s always the way to create Bash aliases or scripts- that’s just one one command from the terminal and faster than opening up a cleaning application!:wink:

This is what I do and my suggestion. You can certainly use BleachBit, a lot of folks do, but remember that it’s a third-party application doing the work for you, so apply it carefully…

I usually use BleachBit before backing up my data drive or imaging my system partition. It can cut down a several 100 MBs to a couple GBs from cached files.

Settings I use:

  • Ran as current user:
    • Bash - clear history
    • Firefox - everything (it's not my main web browser)
    • Google Chrome - just cache
    • LibreOffice - everything
    • System - cache, custom, recent documents list, rubbish bin
    • Thumbnails
    • VLC media player
  • Ran as root:
    • APT - autoclean, autoremove, clean
      • Could do "package lists" too, it just requires sudo apt update the next time you'd like to install stuff.
  • System - cache, localisations, rotated logs, rubbish bin (/root/)
    • Localisations - make sure you set this in the settings! Since I'm :gb:, I only have "en" and "en-GB" checked.

For custom, I have it pointing to a few areas, notably Steam and Spotify:

  • /path/to/steam/appcache/httpcache/
  • /path/to/steam/config/htmlcache
  • /path/to/spotify/Browser/GPUCache
  • /path/to/spotify/Browser/Cache

Right now, there's 1.14 GB and 65.8 MB worth of harmless yet unnecessary files. :package: :clear: All modern operating systems accumulate "cache" intended to speed up the computer... it seems to grow quicker if I've been online a fair bit.

I never used BleachBit to remove kernels, I use this command instead and haven't had a problem:

It helped once identify that I was in fact still booting a 4.4 kernel when my system was "updating" to 4.10...

If ever in doubt, I'd recommend keeping backups/snapshots of your system.


@lah7 Thanks for sharing your Bleach Bit settings. I assume cleaning APT and System as root does a more thorough job. Also, what are your thoughts on the BB’s Deep Scan?

A little off topic, but how do your image your system. I was using ReDo for 16.04, now trying to learn Clonezilla with 18.04.

That is one hell of a command with regex!!:scream:

Btw, how do you keep snapshots of your system?

Not quite, “as root” cleans out root’s home folder (/root/) which might get used if you’re running programs as sudo. The usual user isn’t able to perform the “APT” due to insufficient permissions. For deep scan, root of course would be able to access other folders that are not owned by your user.

A deep scan is only really necessary if you exchange files with other OSes:

  • .DS_Store - Macs create these files. I think it holds view settings for a folder.
  • Backup files - that’s files ending in .bak – pluma for instance can create a copy when you save text files.
  • Temporary files - might be wrong, but that could be files ending in .tmp. I’ve mostly seen that extension used by Windows programs saving in temp folders.
  • Thumbs.db - Windows creates those files, holding settings for a folder.

In some cases it might only be necessary to perform a deep scan once or skip it altogether if you don’t have random files/folders lying about.

I previously used Clonezilla, but these days I’ve gone a more advanced route by tarring my root partition. I have a script to rsync my data partition to a USB backup drive.

I tried your command, it seemed to work but I did get an error in removing a directory.

$ sudo apt-get remove --purge $(dpkg -l 'linux-image-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d')
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
  linux-image-4.15.0-32-generic* linux-modules-extra-4.15.0-32-generic*
0 upgraded, 0 newly installed, 2 to remove and 0 not upgraded.
After this operation, 179 MB disk space will be freed.
Do you want to continue? [Y/n] 
(Reading database ... 215911 files and directories currently installed.)
Removing linux-modules-extra-4.15.0-32-generic (4.15.0-32.35) ...
Removing linux-image-4.15.0-32-generic (4.15.0-32.35) ...
I: /vmlinuz.old is now a symlink to boot/vmlinuz-4.15.0-33-generic
I: /initrd.img.old is now a symlink to boot/initrd.img-4.15.0-33-generic
update-initramfs: Deleting /boot/initrd.img-4.15.0-32-generic
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.15.0-33-generic
Found initrd image: /boot/initrd.img-4.15.0-33-generic
Found Windows Boot Manager on /dev/sda1@/EFI/Microsoft/Boot/bootmgfw.efi
Adding boot menu entry for EFI firmware configuration
(Reading database ... 210942 files and directories currently installed.)
Purging configuration files for linux-modules-extra-4.15.0-32-generic (4.15.0-32.35) ...
Purging configuration files for linux-image-4.15.0-32-generic (4.15.0-32.35) ...
rmdir: failed to remove '/lib/modules/4.15.0-32-generic': Directory not empty

rmdir: failed to remove '/lib/modules/4.15.0-32-generic': Directory not empty

That’s OK, there were some DKMS kernel modules installed for that kernel and the folder wasn’t empty (a feature of rmdir). It would be safe to remove it by hand without any side effects:

sudo rm -rf /lib/modules/4.15.0-32-generic

There could be more leftovers in /lib/modules/ for older kernels too that would be safe to remove if the kernel is no longer on the system.

1 Like