Installing Mozilla's Firefox on Ubuntu

Why would you want to install the Mozilla version of Firefox?
Copy and paste terminal commands
Notes
Commands to remove Mozilla's version
Use a script to automate the commands

Why would you want to install the Mozilla version of Firefox?
There's usually no reason anyone would have to install the Mozilla version of Firefox. The Ubuntu repositories version receives security updates and is integrated with the filesystem. If you use the Mozilla version, you'll have to integrate it with the filesystem so that it launches properly and uses the right multimedia plugins, and you'll also have to do manual security updates.

Some people like to use the Mozilla version because they think it gives better performance. Others want a newer version of Firefox than their version of Ubuntu will offer. Whatever your reasons, this page should help you get the latest Mozilla build of Firefox installed on your system properly.

Copy and paste terminal commands
The fastest and easiest way to get the Mozilla version of Firefox installed is copying and pasting the following commands into the terminal.

These commands assume you've downloaded the Firefox .tar.bz2 file to your home directory (/home/username/):

cp -R ~/.mozilla ~/.mozilla.backup
sudo tar -jxvf firefox-3*.tar.bz2 -C /opt
rm firefox-3*.tar.bz2
sudo mv /opt/firefox/plugins /opt/firefox/plugins.backup
sudo ln -s /usr/lib/xulrunner-addons/plugins /opt/firefox/plugins
sudo dpkg-divert --divert /usr/bin/firefox.ubuntu --rename /usr/bin/firefox
sudo ln -s /opt/firefox/firefox /usr/bin/firefox
That's it.

If you want more explanation as to what these commands actually do, you can read more on the Ubuntu wiki.

Notes
In addition to assuming you have the Firefox .tar.bz2 file in your /home/username directory, the instructions also assume you've never installed the Mozilla version of Firefox to the /opt directory before. If you had installed Mozilla's Firefox 2 previously, then run the removal commands (below) before running the installation commands (above).

Commands to remove Mozilla's version
Sometimes people want to revert back to Ubuntu's Firefox and get rid of the Mozilla version of Firefox. If you want to do that, paste these commands into the terminal:

sudo rm /usr/bin/firefox
sudo dpkg-divert --rename --remove /usr/bin/firefox
sudo rm -r /opt/firefox
It's very important that you paste that last command. Do not retype it, as altering the command in any way (pressing Enter prematurely by accident, for example) could delete more than Mozilla's Firefox.

I've generally found that Firefox profiles work (apart from no-longer-compatible extensions) from version to version of Firefox, but if you have a corrupt Firefox profile and if you used the cp -R ~/.mozilla ~/.mozilla.backup command to back up your Firefox settings before installing the Mozilla version, then you can restore your old settings with these commands:

mv ~/.mozilla ~/.mozilla.mozillafirefox
mv ~/.mozilla.backup ~/.mozilla

Use a script to automate the commands
If you would like a script to automate the installation of Mozilla's Firefox, you can download it here.

It takes a bit longer, but it's slightly different from just copying and pasting the instructions:

  • The script automatically checks to see the latest version of Firefox that's available.
  • The script will download Firefox for you and ask you what localized version you want.
  • The script will try several download mirrors if the first doesn't work.
  • The script allows you to easily install and remove the Mozilla build of Firefox.
  • The script also allows you to easily install and remove the Mozilla builds of Thunderbird and Seamonkey.

If you have suggestions or corrections for these tutorials, please post in this Ubuntu Forums thread or leave a comment on my blog.