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?
11 Answers
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-browserAlternate way is to add the following line
export BROWSER=/usr/bin/firefoxto your~/.bashrcAdd 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.

- 73,717
- 84,513
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
- 537
Googlers, to do this fully scripted (no interaction whatsoever) in a setup script:
sudo update-alternatives --install /usr/bin/x-www-browser x-www-browser /usr/bin/google-chrome 500
sudo update-alternatives --set x-www-browser /usr/bin/google-chrome
…and similary for your favorite editor:
sudo update-alternatives --install /usr/bin/editor editor /usr/bin/pluma 500
sudo update-alternatives --set editor /usr/bin/pluma
- 1,430
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.
- 43,563
The top two answers here both look promising, yet only one of them worked for me. Have you ever wondered why? For the sake of completeness, this is an official wiki page from Debian:
Foreign applications
Default for foreign programs (system-wide)
Programs which are not designed for the user's desktop environment do not obey the browser settings of the desktop environment (GNOME or KDE). For example, Thunderbird ignores desktop environment-specific browser settings. The default browser for generic applications can be changed for the whole system by reconfiguring the x-www-browser alternative.
# update-alternatives --config x-www-browserDefault for foreign programs (user-specific)
Some applications use xdg-open (part of xdg-utils). xdg-settings can be used to both get and change the default browser. Local settings can also be found in the users' home in ~/.config/mimeapps.list.
$ xdg-settings get default-web-browser chromium.desktop$ xdg-settings set default-web-browser firefox-esr.desktop
sudo update-alternatives --config x-www-browser
only shows installed application trough apt-get, for manual installation you can use
sudo update-alternatives --install /usr/bin/x-www-browser x-www-browser /opt/yourapp/yourapp 200
sudo update-alternatives --set x-www-browser /opt/yourapp/yourapp
- 209
first of all, I use Ubuntu 22.04 and wanted to set Midori as my default browser, but this was even not listed in the list of browsers.
Reading a bit discovered that the configuration file to define default browser was:
~/.config/mimeapps.list
Then as I have several browsers I discovered that In order to add to the list of browsers I needed to find which was the *.desktop Application Meta Description of Midori, those files *.desktop are located in several places of ubuntu but mainly on:
/usr/share/applications
With this information and after comparing what changes in the file after setting default browser in ubuntu/settings the following images show how I finally set midori as default browser:
- Find the name *.desktop of midori, in my case was midori-ng.desktop
- Edit the file ~/.config/mimeapps.list
- Add entries of midori-ng.desktop in the list of available brosers.
- In my case midori-ng.desktop was but defined, because didn't pass the parameter or arguments to the app so I couldn't for example open a link that was in a pdf. So I had to edit the midori-ng.desktop file to set the parameter as midori %u.
Added Midori in the combobox of default browsers.
Added Midori as default browser
Edit midori-ng.dekstop
Added missing handler of argument or parameter %u
Midori Now Appears Listed In Settings
- 163
For me, today, running Gnome 3, ~/.config/mimeapps.list is what controls gnome-open <url> and Java's Desktop.getDesktop().browse(new URI(url)). This is what changes there when I run gnome-control-center (the "Details" applet in the settings application from the top right menu) and change Default Applications, Web from Google Chrome to Firefox ESR:
11c11
< x-scheme-handler/http=google-chrome.desktop
---
> x-scheme-handler/http=firefox-esr.desktop`
As hoped, I could revert that from the command line with:
perl -i -wpe 's@x-scheme-handler/http(s?)=firefox-esr.desktop@x-scheme-handler/http$1=google-chrome.desktop@' ~/.config/mimeapps.list
... and put it back with:
perl -i -wpe 's@x-scheme-handler/http(s?)=google-chrome.desktop@x-scheme-handler/http$1=firefox-esr.desktop@' ~/.config/mimeapps.list
- 227
- 2
- 8
Try the following commands:
sudo update-alternatives --config x-www-browser
sudo update-alternatives --config www-browser
- 3,149
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
- 1,413
For me, sensible-browser seems to just call /usr/bin/gnome-www-browser, which symlinks to /etc/alternatives/gnome-www-browser, which symlinks to the browser. To change it, I needed to do this:
sudo rm /etc/alternatives/gnome-www-browser
sudo ln -s ~/bin/firefox /etc/alternatives/gnome-www-browser
You should put the full path to the browser that you want to use in place of ~/bin/firefox.
Now, when I run sensible-browser https://example.com, Firefox opens as expected.
- 1,263