Subscribe to How-To Geek

Set the Default Browser on Ubuntu From the Command Line

Ubuntu Linux has a default browser functionality that will automatically launch the correct browser when clicking on a link in a gnome gui application. It's easy enough to set the default browser using the GUI tools, but sometimes it's easier to set it using the command line client.. for instance, if you are trying to remotely administer a machine.

To change this setting, we'll use the update-alternatives command.

sudo update-alternatives –config x-www-browser

You should see something similar to this. You'll notice that konqueror is the default browser on my computer right now.

$ sudo update-alternatives –config x-www-browser

There are 2 alternatives which provide `x-www-browser'.

Selection Alternative
———————————————–
    1 /usr/bin/firefox
*+ 2 /usr/bin/konqueror

Press enter to keep the default[*], or type selection number:

If I wanted to select firefox as the default browser, I could just type 1 and hit enter.

The Geek is the founder of How-To Geek and a geek enthusiast. When he's not coming up with great how-to articles, he's probably writing at his personal blog. This article was written on 12/5/06 and tagged with: Ubuntu, Ubuntu Tips & Tweaks

Comments (8)

  1. froyd

    im trying to do that but i dont get anything in that list…. my prob is i update from firefox to firefox2, everything is fine besides the fact that some apps when i click on link they dont open the browser anymore ( like gaim ) … im trying to set symlinks but with no luck , so i came to this side, setting default browser but got no luck either

  2. Sneezy melon

    Thanks for sharing. Although, using GUI tools is much easier.

  3. Sneezy melon

    BTW, is there any way of configuring POP/IMAP access for Windows Live Mail in Evolution Mail ??

  4. What is Firefox?

    Thank you! Tell me, how can I change the default email client as well?

  5. Sawtooth

    Good advice. But: I upgraded to ubuntu 8.04 which includes firefox-3 of course, which sucks, of course. After reverting to firefox-2, fixing the eye-damaging fonts, etc. I found that links from my emails/im etc didn't work. I suspected that something like the default browser was "confused" and tried to change that. This led me here. Typing the command I get:
    $ sudo update-alternatives –config x-www-browser
    There is only 1 program which provides x-www-browser
    (/usr/bin/firefox-2). Nothing to configure.

    It seems that only by using the GUI i could add the -2 at the firefox %s command. After I changed it to firefox-2 %s the links worked fine.

  6. lcpetroski

    Great advice, but note that preceding the worh "config", there are two dashes as:
    sudo update-alternatives –config x-www-browser. Hard to see while editing, but it makes all the difference in execution.

  7. va9rant

    thanks for the tip!!! works like a charm :)

  8. va9rant

    had a problem setting firefox to open html files after following this tip (konqueror still was the default file in opening html files), solved the problem after associating it with ff3 in kubuntu 8.04.1 by right-clicking the file, open with, selected ff3 and checked "Remember application association for this type of file" tick box :) just thought I'd add it here…


Leave a Comment




Leave your friendly comment here. If you have a computer help question, leave it on the forums instead.

Note: Your comment may not show up immediately on the site.

Sponsored Links
Getting Started
About How-To Geek
Popular Articles

Copyright © 2006-2008 HowToGeek.com. All Rights Reserved.