3

I have downloaded Firefox, but when I run firefox in Alt+F2 (Gnome 3.4.2), Iceweasel runs instead. I used the type command to find the file apparently responsible for this:

#!/bin/sh

FIREFOX="$(which $0)"
[ -x "$FIREFOX.real" ] && exec "$FIREFOX.real" "$@"

exec iceweasel "$@"

An easy solution is to replace the last line with:

exec [location of downloaded firefox] "$@"

Is there another way to make it so that firefox runs my downloaded copy of firefox instead of iceweasel?

  • This /usr/bin/firefox script is provided by Debian so that users who try to use firefox get something functionally equivalent instead of a "command not found" error. Since it is provided by Debian, it is generally advised to not edit the file, as there are cleaner and easier ways to go about it. The answer depends on how did you install firefox and where did you install it to? – jw013 Jun 27 '14 at 16:07
  • I installed firefox from the web, and know its location in my computer (suppose [location of firefox in folder]). I can do the above to edit the file, but what other ways do you suggest? – user296844 Jun 27 '14 at 16:14
3

For all users on your machine: writing to /usr/bin

The script itself suggests a method for providing an alternative to iceweasel. I presume that the script is called /usr/bin/firefox. Thus, the line

FIREFOX="$(which $0)"

would set FIREFOX to /usr/bin/firefox. Thus, $FIREFOX.real would be /usr/bin/firefox.real. The line

[ -x "$FIREFOX.real" ] && exec "$FIREFOX.real" "$@"

looks to see if an executable with a .real suffix exists and runs that. If it doesn't find it, it falls back to iceweasel. Thus, to bypass iceweasel you need to create firefox.real:

sudo ln -sT "$location_to_firefox" /usr/bin/firefox.real

Note that root privileges are required to write to /usr/bin.

Just for yourself: writing to ~/bin

If you downloaded firefox into your home directory somewhere, use this method. Debian is set up by default so that if you have a bin directory in your $HOME directory, it will prepend it to your path. Thus all you have to do is:

mkdir -p ~/bin && ln -sT "$location_to_firefox" ~/bin/firefox

Once that symlink is in place it will override /usr/bin/firefox. Log out and back in for the changes to take effect. To confirm, run command -v firefox and make sure it prints the path to the firefox in your ~/bin directory.

  • This resolved the issue cleanly. It resembles what I was looking for. Thank you. Note that when he writes "$location_to_firefox", you don't type this, but simply the file location without " ". He took my supposition literally in his answer, which also taught me the meaning of $, as it appears here: www2.linux-training.be/funhtml/ch05s07.html. A good exercise with a fairly good-sized kernel of learning. – user296844 Jun 28 '14 at 22:08
1

Specifically for gnome, there's a debian alternative configuration called gnome-www-browser. Alternatives on debian provides a way of defining a set of possible site-wide alternatives for a given functionality. In the case of gnome browser, it is simply a symlink to the browser launched by the desktop whenever a browser is needed or invoked.

You can configure, list available options, add and remove options with /usr/sbin/update-alternatives (8). For example:

# update-alternatives --list gnome-www-browser
/usr/bin/chromium
/usr/bin/iceweasel
/usr/bin/opera

So let's imagine you've just installed the latest firefox binaries in /opt/firefox, and wish to set it up as the default browser for all gnome users. You would have first to add that new binary to your list of available browsers:

# update-alternatives --install /usr/bin/gnome-www-browser gnome-www-browser /opt/firefox/firefox 100

# update-alternatives --list gnome-www-browser
/opt/firefox/firefox
/usr/bin/chromium
/usr/bin/iceweasel
/usr/bin/opera

# update-alternatives --display gnome-www-browser
gnome-www-browser - auto-mode
  link currently points to /usr/bin/opera 
/opt/firefox/firefox - prority 100
/usr/bin/chromium - priority 40
/usr/bin/iceweasel - priority 70
  slave gnome-www-browser.1.gz: /usr/share/man/man1/iceweasel.1.gz
/usr/bin/opera - priority 200
  slave gnome-www-browser.1.gz: /usr/share/man/man1/opera.1.gz
Current 'best' version is '/usr/bin/opera'

As you can see, each option is tied to a certain priority, which when the alternative is working in auto mode, defines which option is chosen. You can also see that I defined the priority to be 100 for firefox, and that the opera package is installed with a priority of 200 (!), making it the default in auto mode. You can override that decision by setting which option you want to take over:

# /usr/bin/update-alternatives --set gnome-www-browser /opt/firefox/firefox

# update-alternatives --display gnome-www-browser
gnome-www-browser - manual-mode
  link currently points to /opt/firefox/firefox 
/opt/firefox/firefox - prority 100
/usr/bin/chromium - priority 40
/usr/bin/iceweasel - priority 70
  slave gnome-www-browser.1.gz: /usr/share/man/man1/iceweasel.1.gz
/usr/bin/opera - priority 200
  slave gnome-www-browser.1.gz: /usr/share/man/man1/opera.1.gz
Current 'best' version is '/usr/bin/opera'

You see that both the link and the mode have been updated.

As a bonus, you don't need to launch firefox by using alt-F2 anymore.

  • Thanks. Pretty thorough. I suppose this and the first answer are not mutually-exclusive. – user296844 Jun 27 '14 at 22:59
  • Taking a break from the other answer; will look into this later. – user296844 Jun 28 '14 at 22:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.