Delete Chromium History On Exit

This post has updates.

Now that you are using Chromium instead of Chrome, you naturally want to continue to preserve your privacy, without unduly affecting browsing performance.

Inadequate Incognito

In Chromium (or Chrome) there is not a built in way to automatically clean up your history on exit. You can use incognito mode but it is a pain to pick it from the menu or use Shift+Ctrl+N on every launch. In Linux from a terminal, or using a shell script, you can launch incognito mode:

chromium-browser --incognito

But anyway Chromium won’t remember your passwords or allow plugins.

You could use a plugin but then it would have access to all data on your computer and the websites you visit.

Personal Profile

One alternative is to run in normal mode but in a profile of your own choosing. I am using Ubuntu so I will create a shell script. If my user name is aqualeena and I use a script called surfing, it will contain:

# Chromium profile for surfing.
chromium-browser --user-data-dir=/home/aqualeena/.surfing-profile

To make the script executable:

chmod +x surfing

Place you script in ~/bin. If you had to make the bin directory, the next time you login, bin will be added to your path.

On exit I want to delete cache, cookies, and history. I add to my script a number of remove file commands. Be careful with this, you would be wise to back up your data first. The finished script looks like this:

# Chromium profile for surfing.
chromium-browser --user-data-dir=/home/aqualeena/.surfing-profile
echo Removed cache, cookies, and history.
rm -rf /home/aqualeena/.surfing-profile/Default/Cache
rm -rf /home/aqualeena/.surfing-profile/Default/Cookies
rm -rf /home/aqualeena/.surfing-profile/Default/Current*
rm -rf /home/aqualeena/.surfing-profile/Default/History*
rm -rf /home/aqualeena/.surfing-profile/Default/Web*
rm -rf "/home/aqualeena/.surfing-profile/Default/Archived History"
rm -rf "/home/aqualeena/.surfing-profile/Default/Current Session"
rm -rf "/home/aqualeena/.surfing-profile/Default/Local State"
rm -rf "/home/aqualeena/.surfing-profile/Default/Media Cache"
rm -rf "/home/aqualeena/.surfing-profile/Default/Top Sites"
rm -rf "/home/aqualeena/.surfing-profile/Default/Visited Links"

The remove files or directories command, rm -rf is using the recursive and force options to remove directories and their contents recursively and ignore nonexistent files, never prompting. Make sure you get recursion right, you have been warned.

Private Preferences

Run your script, select your search engine and consider the following preferences:

  • Deselect Enable Autofill to fill out web forms in a single click (chrome://settings/personal)
  • Deselect Use a web service to help resolve navigation errors (chrome://settings/advanced)
  • Deselect Use a prediction service to help complete searches and URLs typed in the address bar (chrome://settings/advanced)
  • Select Allow local data to be set for the current session only (chrome://settings/content)
  • Select Block third-party cookies from being set (chrome://settings/content)
  • Select Clear cookies and other site and plug-in data when I close my browser (chrome://settings/content)
  • Select Do not allow any site to track my physical location (chrome://settings/content)

To check if your script is working use these urls in Chromium to view cache, cookies, and history:

    • chrome://cache
    • chrome://settings/cookies
    • chrome://history

Terminating Tips

To start over, remove your profile directory. In /home/aqualeena type:

rm -r .surfing-profile

You can create a launcher for a one click startup:

Launch Chromium in surfing profile

Using a launcher to run Chromium in the .surfing-profile

For Google services that you still use, create a separate profile. Some Google apps require cookies to be set so in chrome://settings/content select:

Allow local data to be set (recommended)

Use a different theme so you can distinguish your .google-profile from your .surfing-profile.

Have you taken any steps to preserve your privacy?


20 Feb 2012 — Changed “Select Block sites from setting any data” to “Allow local data to be set for the current session only.” It was just too inconvenient to be creating exceptions for sites that demanded I set cookies before I logged in. Note that if you still see the blocked cookie icon and the message This page was prevented from setting cookies, then it is a third party cookie.


  1. i love your blog, i have it in my rss reader and always like new things coming up from it.

  2. Thank you for that post. This and some other page about where chromium stores it’s data helped me out writing my own script for auto-deleting ALL cache/history/favicons/etc. (Favicons also store some part of the browsing history.)
    I realise that this blog entry is about 2 two years old and most likely the way chromium worked has changed and will continue to change, but here is my script any way (the script is called chromium and the chromium binary was renamed to chromium_unsafe):

    chromium_unsafe –enable-plugins –enable-user-scripts –enable-extensions
    rm -rf .cache/chromium/*
    cd ~/.config/chromium/Default
    rm -f Visited* Top* Favicons Network* Shortcuts*
    rm -f History* Login* Archived* Cookies*
    rm -rf Local\ Storage Application*

    (This script uses many stars, so it appears to be rather harsh, but still it keeps any bookmarks.)

Speak Your Mind