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/konquerorPress 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.

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




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
Thanks for sharing. Although, using GUI tools is much easier.
BTW, is there any way of configuring POP/IMAP access for Windows Live Mail in Evolution Mail ??
Thank you! Tell me, how can I change the default email client as well?
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.
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.
thanks for the tip!!! works like a charm
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…
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.
just use the GUI ’system’, ‘preferences’, ‘preferred applications’
Sawtooth – Thanks for the tip and now the links work!
“–config” not “-config”
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.
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!
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
This is a cool help site where I have seen all sort of answers regarding ubuntu we get
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?
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
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:)