Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Tried to set the default browser using the GUI tools but this didn't work overall. Is there a way to configure the system wide default browser from command line?

share|improve this question
up vote 17 down vote accepted

Execute the following command in terminal,to change the default browser.

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

Sample output:

karthick@Ubuntu-desktop:~$ sudo update-alternatives --config x-www-browser 
There are 3 choices for the alternative x-www-browser (providing /usr/bin/x-www-browser).

  Selection    Path                    Priority   Status
  0            /usr/bin/google-chrome   200       auto mode
* 1            /usr/bin/firefox         40        manual mode
  2            /usr/bin/google-chrome   200       manual mode
  3            /usr/bin/opera           90        manual mode
  • Press enter to keep the default[*].

  • Right now I have firefox as my default web browser.

  • If i want google-chrome as default browser then I will type 3 and hit enter.


  • If you want to configure a commandline browser,then you have to configure

    sudo update-alternatives --config www-browser

  • Alternate way is to add the following line export BROWSER=/usr/bin/firefox to your ~/.bashrc

  • Add the above line in the last,

    enter code here

Alternative GUI Method:

  • You can also set the default browser in Gnome applications,type the following in terminal and press Enter gnome-default-applications-properties
  • It will Open a Window.Now you can choose your preferred browser to set it default. alt text
share|improve this answer
Another brilliant answer. :-) – Stefano Palazzo Dec 8 '10 at 13:42
My gnome-www-browser is a link to epiphany, my x-www-browser is a link to chromium, but the right click in the terminal (gnome-terminal and terminator) opens the url with firefox :( – Arpad Horvath Apr 10 '12 at 8:51
Is there command line for to set document viewer as default for PDF. – Rahul Raj Mar 2 at 17:26

It depends a bit on what "default browser" exactly means, i.e. for what purpose you want to change the browser. Some programs ignore any system-wide settings and use their own settings.

That said, you can set the default browser for all programs starting the browser with the generic sensible-browser command by exporting the BROWSER variable, e.g. add a line to the file ~/.bashrc:

export BROWSER=/usr/bin/firefox

The other generic way of calling a browser is x-www-browser, this one is handled by the Debian "alternatives" system:

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

If you want to configure a commandline-only browser like lynx, you have to configure www-browser instead.

share|improve this answer

Try the following commands:

sudo update-alternatives --config x-www-browser
sudo update-alternatives --config www-browser
share|improve this answer

Additional to those answer google-chrome has usually a symbolic link to the channel-specific version:

/usr/bin/google-chrome -> /etc/alternatives/google-chrome -> /usr/bin/google-chrome-beta
share|improve this answer

The already suggested methods might not work for some app (e.g. HipChat).

I've had to do:

xdg-settings set default-web-browser chromium-browser.desktop
share|improve this answer

Set Chrome as Default Browser from Command Line

open -a "Google Chrome" --args --make-default-browser

Read complete article here:

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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