We might have multiple web browsers installed on our Ubuntu which we might want to use for different browsing preferences. However, there is always a favorite web browser that we want to use 90 percent of the times for regular Internet use. It is best to have that browser set as the default web browser for your Ubuntu system. This default browser is the one that will open links that you click from any UI application, and this is the one that will open when you enter x-www-browser in your Ubuntu command line.
Setting the default web browser through the Ubuntu UI is very simple. All you need to do is open the Settings utility, move to the Details tab, click on the Default Applications and then select your preferred web browser through the Web drop-down.
This article, however, explains how to achieve the same purpose through the Ubuntu command line. It explains how we can use the update-alternatives utility to update one of the installed browsers as the default one. It is good to learn this trick as we do not always have the UI available. For example, a server administrator or a remote user can easily access the command line and make configurations to the target machine.
We have run the commands and procedures mentioned in this article on a Ubuntu 18.04 LTS system. We are using the Terminal application for using Ubuntu command line. You can open it through the system Dash or the Ctrl+alt+T shortcut.
How to set default Browser on the shell?
Open your Terminal applications and enter the following command as sudo:
$ sudo update-alternatives –config x-www-browser
Please note that only an authorized user on Ubuntu can install, remove, update and configure applications.
This command lists all the available web browsers on your system.
The ‘*’ symbol before the selection number indicated the currently set default web browser.
Simply enter the selection number against a web browser option and hit Enter to set a new default alternative.
By default, this list contains web browsers from the /usr/bin directory. If your web browsers are located somewhere else, for example in /snap/bin, you can add it to the alternatives list by running the following command:
$ sudo update-alternatives --install /usr/bin/x-www-browser x-www-browser /snap/bin/chromium 200
In our case, our Chromium web browser was installed in the /snap/bin folder. Through the above command, we could not only set it as our default browser but also dd it to the update-alternatives list for later use.
Hopefully, through the simple commands described in this article, you will be able to easily set a new default web-browser for your Ubuntu system.