How to set the Default Browser from the Command Line?
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.
Note:
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,
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.
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
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.