SEARCH

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.

Lowell Heddings, better known online as the How-To Geek, spends all his free time bringing you fresh geekery on a daily basis. You can follow him on if you'd like.

  • Published 12/5/06

Comments (24)

  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…

  9. bravespear

    I am using Kubuntu Hardy 8.04.
    I have typed the command:

    sudo update-alternatives –config x-www-browser

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

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

    Press enter to keep the default[*], or type selection number: 1
    Using ‘/usr/bin/firefox-3.0′ to provide ‘x-www-browser’.

    I have selected 1 for firefox but when I create a desktop url pointing to http://www.google.com it automatically opens in Konqueror.

    Any ideas? I need to setup Firefox as the default web browser in a LiveCD I am creating.

  10. bunky

    just use the GUI ‘system’, ‘preferences’, ‘preferred applications’

  11. Ben

    Sawtooth – Thanks for the tip and now the links work!

  12. RMY

    “–config” not “-config”

  13. Navin

    Thanks for this great tip. I just wanted to add that you could use ‘–set’ instead of ‘–config’ to set the path non-interactively. Like so:

    sudo update-alternatives –set x-www-browser /usr/bin/firefox

    Great, if you want to use this command in a script.

  14. Noah Coad

    How about for Windows? Any idea how to set the default web browser (Opera, Safari, Chrome, IE, Firefox, etc) from the command line in Windows (XP/Vista/Win7)? thanks!

  15. V.Balaviswanathan

    Hi I happen to use mepsis on my laptop and I am using KDE as my desktop. I configured wrongly and when I open trash can it opens with firefox and it says “This application cannot be opened in firefox” and how do I retreive it back to open in Konqueror. Please help me

  16. V.Balaviswanathan

    This is a cool help site where I have seen all sort of answers regarding ubuntu we get

  17. Ethnopunk

    Firefox 3.5 always comes up as default, but it doesn’t show up as default here:

    sudo update-alternatives –config x-www-browser

    There are 10 alternatives which provide `x-www-browser’.

    Selection Alternative
    ———————————————–
    1 /usr/bin/firefox-3.0
    2 /usr/bin/opera
    3 /usr/bin/seamonkey
    4 /usr/bin/midori
    5 /usr/bin/epiphany-gecko
    6 /usr/bin/firefox-2
    *+ 7 /usr/bin/galeon
    8 /usr/bin/kazehakase
    9 /usr/bin/netsurf
    10 /usr/bin/firefox-3.5

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

    I have blackbox as alternative session, and Galeon is default there. How do I change the default for Gnome?

  18. fak3r

    this is exactly what I was looking for, only issue is I needed two dashes before the ‘config’ flag:

    sudo update-alternatives –config x-www-browser

    Thanks

  19. oto

    Thanks it really helped :)
    Usualy I don’t leave such comments becouse I consider them not usefull and close to spam, but I want to show mmy appreciation:)

  20. Julio C.

    Thanks! was trying to do it wrong, guidance helped.
    cheers.

  21. Thomas Nkmo

    Please Help Me to install the mozila fire fox to my lap top

  22. Alexander Fisher

    I have a situation where a client had email client authentication
    problems with Thunderbird,moved them onto Evolution 2.8.2 which
    works much better with additional features.
    However I have 2 issues that perplexes me.

    1. How do I set Evolution as the default mail client in Windows, when
    Thunderbird was installed I could set it as the default against
    Outlook or Outlook express.Not possible with Evolution, is there
    a registry setting that one can force this?

    2. From within a mail received in Evolution, I cannot open any web URL,
    it gives me an error indicating – “Could not open the link,
    No application is registered as handling this file.” I checked fix
    for it on the web that indicate that the default security setting
    in Vista and Windows 7 with regard to Java Script has been set off.
    I changed that in internet security settings of control panel, but still
    no luck. Same as issue above, can one force Firefox as default
    web browser to be activated from within the Evolution Mail?

  23. Jay

    Thank youuuuuu! This worked perfectly for me :] switched the default browser from chrome to chromium

  24. SOPHIA WILLIAMS

    PLS HELP TO OPEN MY YAHOO MAIL I WAS HAVING A PROBLEM ABOUT MY BOX WHICH I CAN NOT OPEN THAT WAS FAULT FROM JAVA SPRIT

Enter Your Email Here to Get Access for Free:

Go check your email!