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. This article was written on 12/5/06 and tagged with: Ubuntu, Ubuntu Tips & Tweaks

Daily Email Updates

You can get our how-to articles in your inbox each day for free. Just enter your name and email below:


Name:
Email:
Similar Articles Featured Wiki Articles
Latest Software Reviews Quick Linux Tips
Geek Arcade Popular Forum Threads

Comments (16)

  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


Leave a Comment




Leave your friendly comment here.

If you have a computer help question, click here to 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
What Is That Process?
svchost.exe
jusched.exe
dwm.exe
ctfmon.exe
wmpnetwk.exe
wmpnscfg.exe
rundll32.exe
wfcrun32.exe
Ipoint.exe
Itype.exe
Wfica32.exe
Mobsync.exe
Cmd.exe
Dpupdchk.exe Adobe_Updater.exe

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