1. Home
  2. Linux

How to clean install Firefox on Linux, from scratch

Mozilla Firefox is one of the most used web browsers in the world, second only to Google’s Chrome browser. It’s everywhere, due to a long history of being an excellent tool for navigating the world wide web. It’s so popular that Firefox is the default web browser on pretty much all Linux operating systems because it’s open source, modern, and is free to distribute.

Firefox is easily installable on many Linux distributions, due to its ubiquitous nature. However, not all Linux OSes have Firefox in their software repositories. Even worse, some that do (such as Debian or OpenSUSE Leap) don’t offer the latest release, and users are stuck with an older version of the browser without the newest features to enjoy.

In this tutorial, we’ll show you how to get the absolute latest version of Mozilla Firefox on Linux operating systems that do not distribute the browser, or have older, outdated releases.

Download Firefox DL installer

The old fashion way of installing Firefox from scratch involves downloading the latest release binary archive from Mozilla’s website. Generally, going this route is useful but not recommended for everyone as with each update you’ll need to re-download the release and do the installation all over again. A better way to go about installing Mozilla Firefox from scratch on a Linux operating system is to use the “Firefox DL and install” script because it allows anyone (even newbies) to automate installing the browser and updating it too.

The script is on GitHub. It’s a simple tool. To get it, open up a terminal window on your Linux PC by pressing Ctrl + Alt + T or Ctrl + Shift + T on the keyboard. Then, use the wget downloader tool to grab it from the developer’s GitHub repository.

wget https://raw.githubusercontent.com/arnaudbey/firefox-dl-n-install/master/firefox_dl_n_install.sh

Can’t use wget? Feel free to clone the code with the git tool instead.

git clone https://github.com/arnaudbey/firefox-dl-n-install.git

With the script done downloading to your Linux PC, you’ll need to update the script’s permissions. To do this, use the chmod command.

sudo chmod +x firefox_dl_n_install.sh

Or, for the GitHub version, do:

sudo chmod +x ~/firefox-dl-n-install/firefox_dl_n_install.sh

Install Firefox with DL installer

The Firefox installation script isn’t entirely automatic, and won’t do anything without user-input. To start, go to the terminal and use the sh command to execute the script.

sh firefox_dl_n_install.sh

Or

sh ~/firefox-dl-n-install/firefox_dl_n_install.sh

With the script running, you’ll see a prompt on screen. In this prompt, you’ll see several versions of Mozilla Firefox to choose from. These versions are Firefox Stable, Firefox Beta, Firefox Aurora, and Firefox Nightly.

Type a number in the terminal to make a selection. Shortly after, the tool will start downloading the Firefox Browser from Mozilla’s website and install the browser.

When the script is done running, close the terminal window by typing in the exit command.

Note: need to update Firefox? Re-run the script and choose the same release. It’ll overwrite everything and get you to the latest version.

exit

Launch the newly installed Firefox browser on your Linux PC by pressing Alt + F2 then typing in “firefox” into the command box.

Create a desktop shortcut

The Firefox installation script grabs the source code and puts all the files in the right place, but it doesn’t make a desktop shortcut.

To create a new desktop shortcut, do the following.

Step 1: Create a new desktop file.

sudo touch /usr/share/applications/firefox.desktop

Step 2: Open up the firefox.desktop file in Nano.

sudo nano -w /usr/share/applications/firefox.desktop

Step 3: Paste the code into the text editor.

Please note that if you choose anything other than Firefox Stable, you must change each instance of “Exec=” in the shortcut code below to your release of Firefox. It should look like firefox-release.

[Desktop Entry]
Version=1.0
Name=Firefox Web Browser
Comment=Browse the World Wide Web
GenericName=Web Browser
Keywords=Internet;WWW;Browser;Web;Explorer;
Exec=/usr/local/bin/firefox %u
Terminal=false
X-MultipleArgs=false
Type=Application
Icon=firefox
Categories=GNOME;GTK;Network;WebBrowser;
MimeType=text/html;text/xml;application/xhtml+xml;application/xml;application/rss+xml;application/rdf+xml;image/gif;image/jpeg;image/png;x-scheme-handler/http;x-scheme-handler/https;x-scheme-handler/ftp;x-scheme-handler/chrome;video/webm;application/x-xpinstall;
StartupNotify=true
Actions=new-window;new-private-window;

[Desktop Action new-window]
Name=Open a New Window
Exec=/usr/local/bin/firefox -new-window

[Desktop Action new-private-window]
Name=Open a New Private Window
Exec=/usr/local/bin/firefox -private-window

Step 4: Save the code with Ctrl + O and exit Nano with Ctrl + X.

Step 5: Update the firefox.desktop file permissions.

sudo chmod +x /usr/share/applications/firefox.desktop

With the permissions up to date, Mozilla Firefox will be ready to use. To launch it, check the “Internet” section of your app launcher.

Uninstall Firefox

So, you’ve decided not to go with the Firefox browser on your Linux PC. The trouble is since the browser was set up through a script, it cannot be uninstalled through the system’s package manager. Instead, you’ll need to manually delete all of the files by hand.

The installer script places the browser files in several locations on the system. To uninstall Firefox, you’ll need to open up a new terminal session and gain root access in the shell by using the su command.

su -

Or, if you can’t use the su command, try sudo instead.

sudo -s

Now that you’ve got root access move into the /opt/ directory.

cd /opt/

From here, use the rm command to delete the browser’s files and sub-directories.

rm -rf firefox*

After deleting the browser files, move to the /usr/share/applications directory on your Linux PC with the CD command.

cd /usr/share/applications 

rm firefox.desktop

Finally, delete the binary file from the /usr/local/bin/ directory.

rm firefox*

Leave a comment