How to install Firefox using Mozilla repository on Debian 12

Endrit Qerreti

Endrit Qerreti

When it comes to Debian 12, Firefox ESR comes pre-installed. However, in this tutorial, we'll be installing the non ESR version of Firefox, by using the official Mozilla repository.

The difference between Firefox ESR and Firefox non ESR is that, the ESR version will receive updates once a year, while the non ESR version will receive updates every 4 weeks.

In this tutorial, you will learn how to install Firefox using Mozilla repository on Debian 12.

Step 1 - Create keyrings directory

The /etc/apt/keyrings is the directory where we will download Firefox GPG key. If this directory doesn't exist on your Debian machine, you can easily create it.

To do so, simply run the command below.

sudo install -d -m 0755 /etc/apt/keyrings

Step 2 - Download Mozilla GPG key

Once you create the keyrings directory /etc/apt/keyrings, now you can proceed to import Mozilla GPG key on this directory.

Mozilla GPG key can be easily imported on your debian system, by using wget. So before importing the GPG key, ensure that wget is installed on your system.

To import Mozilla GPG key, simply execute the following.

wget -q https://packages.mozilla.org/apt/repo-signing-key.gpg -O- | sudo tee /etc/apt/keyrings/packages.mozilla.org.asc > /dev/null

Step 3 - Import Mozilla GPG key

Mozilla GPG key should be now imported on your system. To ensure that the key that we imported is genuine, run the command below.

gpg -n -q --import --import-options import-show /etc/apt/keyrings/packages.mozilla.org.asc | awk '/pub/{getline; gsub(/^ +| +$/,""); if($0 == "35BAA0B33E9EB396F59CA838C0BA5CE6DC6315A3") print "\nThe key fingerprint matches ("$0").\n"; else print "\nVerification failed: the fingerprint ("$0") does not match the expected one.\n"}'

The fingerprint should be 35BAA0B33E9EB396F59CA838C0BA5CE6DC6315A3, this means that Mozilla GPG key is genuine, and you can proceed to install Mozilla Firefox.

Step 4 - Create Mozilla Repository

Now that you have imported Mozilla GPG key, and verified that Mozilla GPG key is genuine, proceed to create Mozilla repository on your Debian 12 system.

Having Mozilla APT Repository on your Debian 12 system, allows you to install Mozilla firefox via the terminal, and also allows you to update your Firefox browser whenever a new update is released.

Setting up Mozilla Repository on Debian 12 is quite easily, and it can be done by simply running the command below.

echo "deb [signed-by=/etc/apt/keyrings/packages.mozilla.org.asc] https://packages.mozilla.org/apt mozilla main" | sudo tee -a /etc/apt/sources.list.d/mozilla.list > /dev/null

Step 5 - Prioritize Mozilla Repository

Firefox ESR version is available in the main repository of Debian 12, meaning when you are installing Firefox ESR version, the system will download the firefox-esr package from the main Debian 12 repository.

Since we added Mozilla repository on our Debian 12, we want to make sure that the firefox packages are also being downloaded from the newly created repository, and not from the default repositories.

So, what we need to do is, tell APT to prioritize Mozilla repository when downloading Firefox.

To do so, simply execute the command below.

echo '
Package: *
Pin: origin packages.mozilla.org
Pin-Priority: 1000
' | sudo tee /etc/apt/preferences.d/mozilla

Step 6 - Update Debian 12 system

After setting up Mozilla repository, you need to update your Debian 12 system, so that Mozilla repository is added on the sources.list file.

To update your Debian 12 system, execute the command below.

sudo apt update

Once the updating process starts, you should see Mozilla repository listed, this means that Mozilla repository is successfully added and ready to be used to download Firefox and Firefox updates.

Step 7 - Install Mozilla Firefox

Now that Mozilla firefox is configured on your Debian 12 system, and prioritized over the default Debian 12 repository, all you have to do now is install Firefox.

To install Firefox non ESR version on Debian 12, simply run the command below.

sudo apt install firefox

Step 8 - Launch Firefox

Firefox is now installed on your Debian 12 system. To launch Firefox on Debian 12, you can do so by using terminal, or via applications menu.

Launching firefox via terminal on Debian 12, is simple. Simply launch terminal, by pressing CTRL + ALT + T, and issue the following command.

firefox

To launch Firefox via applications menu, click Activities > Search for :Firefox > Firefox

As you can see, Firefox deb version is running.

Uninstalling Mozilla Firefox on Debian 12

To uninstall Mozilla Firefox deb version on Debian 12, is very easy to do so.

The uninstalling method depends on the method you used to install Firefox. For example, in this tutorial, we installed Firefox by setting up Mozilla firefox repository.

So in order to completely remove Firefox from your Debian 12, first you must remove the repository that we created, the GPG key, and then proceed to uninstall the firefox package.

1) Remove Mozilla Firefox repository.

Removing Mozilla Firefox repository is done in cases when you don't want your Debian 12 system to install Mozilla Firefox after updating your system.

To do so, simply run the command below.

sudo rm /etc/apt/sources.list.d/mozilla.list

2) Remove Mozilla GPG key.

To remove Mozilla GPG key from your Debian 12 system, simply execute the following.

sudo rm /etc/apt/keyrings/packages.mozilla.org.asc

3) Uninstall Firefox deb version on Debian 12

Once you have removed Mozilla repository and the GPG key, you can now proceed to uninstall Firefox.

To do so, simply run the command below.

sudo apt remove firefox

Conclusion

In this tutorial, you learned how to install Mozilla Firefox non ESR version on Debian 12, via the official Mozilla APT repository.

By now you should be able to use Mozilla Firefox on your Debian 12 system.