Does your Firefox web browser have a large cache of temporary files? Do you have an embarrassing web browsing history? Has it been a while since you last cleared your Firefox cache? If you answered yes to any of the above questions, you've come to the right guide.

In this tutorial, we'll show step by step instructions for clearing the cache in Firefox on a Linux system. You can do this either via GUI or command line. We'll show the instructions for both methods below.

In this tutorial you will learn:
  • How to clear Firefox cache via GUI
  • How to clear Firefox cache via command line
Clearing the cache in Firefox on Linux
Clearing the cache in Firefox on Linux
Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Any Linux distro
Software Mozilla Firefox
Other Privileged access to your Linux system as root or via the sudo command.
Conventions # - requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ - requires given linux commands to be executed as a regular non-privileged user

Clear Firefox cache via GUI

To clear the cache in Firefox, which can optionally include browsing history, cookies, active logins, and form history, open Firefox on your system and follow along with the steps below.

  1. Click the options menu (three stacked lines in the upper right corner), and then Preferences.

    Open the Preferences menu
    Open the Preferences menu

  2. SUBSCRIBE NEWSLETTER & RSS
    Subscribe to RSS and NEWSLETTER and receive latest Linux news, jobs, career advice and tutorials.


  3. Next, click on the Privacy & Security tab.

    Click on the Privacy and Security tab
    Click on the Privacy and Security tab
  4. Scroll down part way and you'll see a section called History. Click on the Clear History button, where you can choose to clear the cache and other browsing history files.

    Choose what to clear and select a time range
    Choose what to clear and select a time range
  5. You can also find the Cookies & Site Data section, which will show you how much space your cache files are consuming, and give you the option to clear them.

    This area shows how much space the cache is using and gives options to clear or manage it
    This area shows how much space the cache is using and gives options to clear or manage it

That's all there is to it. Notice also that you can configure Firefox to clear the cache, cookies, and/or web browsing history automatically each time the browser is closed. You can now exit Firefox or resume your browsing activities after you've finished clearing the cache and other data if you chose to.

Clear Firefox cache via command line

When clearing the cache via Firefox's GUI menus, all it's really doing is deleting files from your computer. These same files can be deleted without Firefox, too, such as via the command line. There are actually quite a few things you can do with Firefox from the Linux command line.

Firefox stores the cache (temporary files such as images) in one directory, and your browsing history (websites visited, form history, etc.) inside another directory as .sqlite files.

Depending on your Firefox installation, these directories will be in a predictable place across most Linux systems. If Firefox was installed by default on your system or installed via your system's package manager, you can use the following commands to clear Firefox's cache.

On Ubuntu, Debian, Arch Linux, Manjaro, and any derivatives of those distributions, these commands will work:



Clear cache files:

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

Clear browsing history (cookies, history, forms):

$ rm ~/.mozilla/firefox/*release/*.sqlite

On CentOS, Fedora, and Red Hat, these commands will work:

Clear cache files:

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

Clear browsing history (cookies, history, forms):

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

As you can see, the directory names differ just a little between some popular distros, so we have to change the command accordingly. There is a chance that your system uses a different structure altogether, in which case you'd have to improvise and change the directories as needed. The same can be said if you installed Firefox manually into a different location.

If clearing the cache for a user other than the one to which you're currently logged in, be sure to specify the home directory as an absolute path, such as /home/linuxconfig/.cache/ ... instead of ~/.cache/ ....

Restart Firefox in order for all these changes to take effect. To configure your system to clear these files automatically, you could schedule a cron job.

Conclusion

It's good practice to clear Firefox's cache every once in a while, just to declutter the hard drive and get rid of old session cookies, etc. In this guide, we saw two different methods for clearing the cache in Mozilla Firefox on Linux. The GUI method is the traditional way, but we also learned how deleting the appropriate files via command line can accomplish the same task. Depending on your situation, one method might work better for you than another. Both methods can be used to automatically clear the cache at regular intervals for you.

FIND LATEST LINUX JOBS on LinuxCareers.com
Submit your RESUME, create a JOB ALERT or subscribe to RSS feed.
LINUX CAREER NEWSLETTER
Subscribe to NEWSLETTER and receive latest news, jobs, career advice and tutorials.
DO YOU NEED ADDITIONAL HELP?
Get extra help by visiting our LINUX FORUM or simply use comments below.