Use BleachBit’s command line interface to preview and run cleaners on Windows or Linux, including from a terminal without a graphical desktop.

To automate cleaning, see cron on Linux or Windows Task Scheduler.

Quick start

First list the cleaners available on your system, then preview a cleanup. The examples preview clearing the Firefox cache without deleting anything.

Windows

Use bleachbit_console.exe to see the output in Command Prompt. These examples use the default path for an all-users installation on 64-bit Windows. If you installed BleachBit elsewhere or use the portable version, substitute the full path to your copy.

"C:\Program Files (x86)\BleachBit\bleachbit_console.exe" --list-cleaners
"C:\Program Files (x86)\BleachBit\bleachbit_console.exe" --preview firefox.cache

For the remaining examples, use the full path to bleachbit_console.exe wherever a command starts with bleachbit.

Linux

In a terminal, run:

bleachbit --list-cleaners
bleachbit --preview firefox.cache

Without arguments, bleachbit opens the graphical interface if a display is available. Clipboard cleaning requires an X session, which is generally not available over SSH or in cron.

Video

This video introduces the command line interface for Windows.

Listing options

--list-cleaners (short form -l) lists the available options in cleaner.option format, such as firefox.cache.

Preview

--preview (short form -p) shows what BleachBit would delete or change without running the cleanup.

Deleting files

After reviewing the preview, replace --preview with --clean (short form -c) to make the changes. To clear the Firefox cache, run:

bleachbit --clean firefox.cache

To compact Firefox databases without clearing the cache, use firefox.vacuum instead. The scheduling examples use this option.

Including multiple cleaners and options

Preview and cleaning modes accept the same options for including and excluding cleaners and options.

Multiple arguments are allowed. To preview deleting Firefox cache and Opera cache, list them separated by a space:

bleachbit --preview firefox.cache opera.cache

Wildcards are allowed for options, so to preview deleting all options for Opera, run:

bleachbit --preview opera.*

Wildcards are not allowed for cleaners, so do not run bleachbit --preview *.*.

To select the same options as in the GUI, use --preset, which may be combined with other options:

bleachbit --preview --preset firefox.cache

To enable all cleaners and options that do not have a warning, use --all-but-warning, which may be combined with other options. Use this with caution, as it will delete many files.

bleachbit --preview --all-but-warning firefox.cache

Excluding options

To except cleaning options, combine --except with inclusion options. The following previews all of Firefox except cookies.

bleachbit --preview firefox.* --except firefox.cookies

These three commands are equivalent: they include all Firefox and Chromium options except their passwords. The first option demonstrates that --except accepts multiple cleaner options, separated by commas.

bleachbit --clean firefox.* chromium.* --except firefox.passwords,chromium.passwords
bleachbit --clean firefox.* chromium.* --except firefox.passwords --except chromium.passwords
bleachbit --clean chromium.* --except firefox.passwords firefox.*  --except chromium.passwords

However, the following command will delete passwords in Chromium.

bleachbit --clean firefox.* chromium.* --except firefox.passwords chromium.passwords

Notes:

  • The order of positive and negative options does not matter.
  • --except is processed after positive options.
  • Each --except accepts exactly one string, which may be comma delimited.
  • --except can be used multiple times.
  • --except can be combined with --preset.
  • --except does not accept wildcards.
  • --except was introduced after BleachBit 5.0.2.

Overwriting files

To overwrite the contents of files, so they cannot be undeleted later, add --overwrite:

bleachbit --overwrite --clean firefox.cache

Without --overwrite, BleachBit checks the configuration set in the graphical user interface.

Shredding files

To shred any file, so its contents cannot be recovered, use --shred. While --overwrite refers to the files identified by --clean, the option --shred shreds any file anywhere. For example, this shreds one file named yoga_emails.txt:

bleachbit --shred ~/yoga_email.txt

To shred all files under a directory, pass the name of the directory like this:

bleachbit --shred "C:\Microsoft Exchange\Top Secret Emails\"

Wiping empty space

When files are deleted without shredding, the contents might be recoverable from the disk’s empty space. To prevent recovery from empty space, you can wipe the empty space. Unlike wiping specific files, wiping empty space takes a long time.

You might want to wipe empty space for each logical drive. For example, on Windows you might wipe C: and D:, if you write sensitive files to both. On Linux, you might want to wipe / and /home if they are separate partitions and if you write sensitive information to both.

To wipe any partition, pass any writable directory in that partition to --wipe-empty-space. For example:

bleachbit --wipe-empty-space ~/.cache/

Wiping empty space does not change how much free space is left, when the process is done. For example, if you start with 10GB free, then you will still have 10GB free when the process is done.

BleachBit 5.0.2 and earlier used --wipe-free-space instead of --wipe-empty-space.

cron example (Linux)

To vacuum Firefox each night at 03:00, run this to edit cron jobs:

crontab -e

and add this line:

0 3 * * * bleachbit --clean firefox.vacuum

Windows Task Scheduler

To vacuum Firefox each night at 03:00 on Windows 10 or 11, create a task that runs in preview mode first:

  1. Open Task Scheduler from the Start menu.
  2. Click Create Basic Task, name the task, and click Next.
  3. Select Daily, click Next, set the start time to 03:00, and click Next again.
  4. Select Start a program and click Next.
  5. Next to Program/script, click Browse and select your copy of bleachbit_console.exe.
  6. In Add arguments (optional), type --preview firefox.vacuum, then click Next and Finish.
  7. In Task Scheduler Library, select the task and click Run. After it finishes, check Last Run Result. To see what BleachBit would change, run the same preview command in Command Prompt.
  8. When ready to enable cleaning, open the task’s properties. On the Actions tab, edit the action and change the arguments to --clean firefox.vacuum.

If you use --preset, run the task under the same Windows account that saved the cleaner selections in BleachBit.