Skip to content

Instantly share code, notes, and snippets.

@mikbuch
Last active August 1, 2022 21:51
Show Gist options
  • Save mikbuch/ee30a18b9738da8a51039ce0875c093c to your computer and use it in GitHub Desktop.
Save mikbuch/ee30a18b9738da8a51039ce0875c093c to your computer and use it in GitHub Desktop.
How to update Firefox on Linux (Ubuntu)

How to update Firefox on Linux (Ubuntu)

Steps to download and install the latest Firefox

From the Firefox documentation pages:

Please use download.mozilla.org to retrieve the latest Firefox release. For example, if you wish to download the US English installer for Windows (32bit) the url is https://download.mozilla.org/?product=firefox-latest&os=win&lang=en-US This could be pasted into the location bar of a browser, or used with curl or wget, e.g. wget -O FirefoxSetup.exe "https://download.mozilla.org/?product=firefox-latest&os=win&lang=en-US" For other operating systems replace 'os=win' with: Windows 64bit os=win64 OS X os=osx Linux x86_64 os=linux64 Linux i686 os=linux Source, with more language codes listed: http://archive.mozilla.org/pub/firefox/releases/latest/README.txt

Source: https://www.reddit.com/r/firefox/comments/vriu2d/comment/ievigel/?utm_source=share&utm_medium=web2x&context=3

So, the one-liner to download the latest Firefox for Linux is:

wget -O firefox-latest.tar.bz2 "https://download.mozilla.org/?product=firefox-latest&os=linux64&lang=en-US"

Potential script

Note! The contents below in this document was an simplistic experimental version of the script. For the most up to date version of the script please refer to the update-firefox-linux.sh file below (a second file in this gist).

In order to download and run the script, use the below command:

curl -s https://gist.githubusercontent.com/mikbuch/ee30a18b9738da8a51039ce0875c093c/raw/7ffe59592b464deec8dca6de02d3cf28e2c452ff/update-firefox-linux.sh | sudo bash

Source on how to run bash script from an URL (via HTTP(S)): Baeldung Linux post

# Remove backup, if there is any
sudo rm -rf /opt/firefox_bak

# Download the latest version of the Firefox browser (use the `/tmp` directory to save the tarball there)
wget -O /tmp/firefox-latest.tar.bz2 "https://download.mozilla.org/?product=firefox-latest&os=linux64&lang=en-US"

# Backup the old version of the Firefox
sudo mv /opt/firefox /opt/firefox_bak

# Untar the new Firefox
sudo tar xjf /tmp/firefox-latest.tar.bz2 -C /opt

# Remove the tar from the `/tmp` directory
rm -r /tmp/firefox-latest.tar.bz2

Additional materials:

bash oneliner with a curl HEAD Request to get the info and cut to parse it from the location header

PRODUCT=firefox-latest;OS=win;LANG=en-US;curl -s -I "https://download.mozilla.org/?product=$PRODUCT&os=$OS&lang=$LANG" -o/dev/null -w '%{redirect_url}' | cut -d'/' -f7

Output:

102.0

Modify arguments (PRODUCT, OS, LANG) as required.

#!/bin/bash
#update-firefox-linux.sh
# Run as root:
# sudo bash update-firefox-linux.sh
# Remove backup, if there is any
# TODO: Add if clause, otherwise this may cause an error which will terminate the script
sudo rm -rf /opt/firefox_bak
# Download the latest version of the Firefox browser (use the `/tmp` directory to save the tarball there)
wget -O /tmp/firefox-latest.tar.bz2 "https://download.mozilla.org/?product=firefox-latest&os=linux64&lang=en-US"
# Backup the old version of the Firefox
sudo mv /opt/firefox /opt/firefox_bak
# Untar the new Firefox
sudo tar xjf /tmp/firefox-latest.tar.bz2 -C /opt
# Remove the tar from the `/tmp` directory
rm -r /tmp/firefox-latest.tar.bz2
@mikbuch
Copy link
Author

mikbuch commented Jul 13, 2022

PPA Firefox Canonical

https://ubuntuhandbook.org/index.php/2022/04/install-firefox-deb-ubuntu-22-04/

https://launchpad.net/~ubuntu-mozilla-security/+archive/ubuntu/ppa

sudo add-apt-repository ppa:ubuntu-mozilla-security/ppa
sudo apt update

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment