I want to clear my firefox cache and cookies from terminal.
What can i do?

  • I just tried deleting everything from the preferences menu, and it deleted web content cache, you just have to choose everything, close the windows. Once open again the cache was 0.
    – Mitch
    Oct 30, 2013 at 7:50

4 Answers 4


To clean the cookies from terminal you can use the following command:

rm ~/.mozilla/firefox/*.default/cookies.sqlite

To clean all the cache, you can use:

rm ~/.mozilla/firefox/*.default/*.sqlite ~/.mozilla/firefox/*default/sessionstore.js
rm -r ~/.cache/mozilla/firefox/*.default/*

But, better you can make a backup of these files if you want to restore them latter:

mkdir -p ~/.mozilla/firefox/backup ~/.cache/mozilla/firefox/backup
mv ~/.mozilla/firefox/*.default/*.sqlite  ~/.mozilla/firefox/backup
mv ~/.mozilla/firefox/*.default/sessionstore.js ~/.mozilla/firefox/backup
mv ~/.cache/mozilla/firefox/*.default/* ~/.cache/mozilla/firefox/backup
  • 1
    It clears all my browser's history,weblogins etc.But it still shows your web content cache is currently using 30 MB of disk space under Network Tab after restarting the browser. Oct 30, 2013 at 7:20
  • 1
    @AvinashRaj Ah, sorry, see my new edits. Oct 30, 2013 at 7:32
  • rm -r ~/.cache/mozilla/firefox/*.default/* command shows no such file or directory.There was no mozilla folder inside .cache directory. Oct 30, 2013 at 7:43
  • @AvinashRaj Probably you deleted already. Oct 30, 2013 at 7:45
  • In Mint Mate the command differ a little bit: mkdir -p ~/.mozilla/firefox/backup ~/.cache/mozilla/firefox/backup <br> mv ~/.mozilla/firefox/*.default*/*.sqlite ~/.mozilla/firefox/backup <p> mv ~/.mozilla/firefox/*.default*/sessionstore.jsonlz4 ~/.mozilla/firefox/backup <p> mv ~/.cache/mozilla/firefox/*.default*/* ~/.cache/mozilla/firefox/backup<p>
    – Peterling
    May 7, 2018 at 19:21

I would like to weigh in on this issue. I have set Firefox to automatically clear all cache, cookies, etc., when I quit.

Firefox menu: Edit > Preferences > Privacy

History: Select "Use Custom Settings for History"

  • All items are checked
  • Always accept all cookies, but keep until I close Firefox
  • Clear history when FF closes: Settings: Everything is checked except Delete Saved Passwords.

If I want to clear the history, etc. while Firefox is running, I simply hit Ctrl-Shift-Delete and choose what to delete.

If Firefox is NOT running, then there is no need to run the script, as the offending stuff has already been deleted. ALMOST. Turns out all the thumbnails are still resident in ~/.cache/thumbnails/normal and ~/.cache/thumbnails/fail. For these, I wrote a little script:

echo "shredding cache"
find ~/.cache/thumbnails -type f -name "*.png" -exec shred -f -u -z -n 1 {} \;
echo "finished shredding"

I fire that on a cronjob, every 3 hours.

But an even simpler way is to run bleachbit. Just as fast to click bleachbit off the menu as it is to open a terminal and run a script. For me, anyway.

Good luck!


The proper way of clearing the Firefox's cache (execute as a user, not root):

$ rm -rf ~/.cache/mozilla/firefox/????????.*/cache2/*

The proper way of clearing the Firefox's cookies (execute as a user, not root):

$ rm ~/.mozilla/firefox/????????.*/cookies.sqlite

Works for both Debian and Ubuntu.

Works for multiple Firefox user profiles.


I at least found a proper solution:

  1. First go to your home location
  2. Press ctrl+h
  3. Open folder .cache
  4. Open folder mozilla
  5. Open folder firefox
  6. Open the (anything).default folder
  7. Open the cache folder
  8. Delete all folders in this
  9. Then open Firefox
  10. Go to edit, preferences and delete all cache and cookies once

and i assure u the your problem will be solved

  • 6
    OP wants to use the terminal and not a file manager. So your answer doesn't apply.
    – user25656
    Jan 14, 2014 at 18:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .