When you click a link to open any website, it will open in a default browser set by the operating system. Most Linux distributions ships with a Mozilla Firefox browser installed and set by default. So if you have never changed the default settings, then all your links or URLs will always be open in the Mozilla Firefox. However, if you do not like your default browser, there is a way to change it. Linux OS allows you to change your default browser for opening the links to websites. First, you will need to install a new browser before setting it as a default one.
It is very easy to change a default web browser from a graphical user interface. All you have to do is to open the Settings application, navigate to the Details tab, select the Default Applications tab, and then pick your preferred choice of browser from the drop-down menu.
However, in this article, we will explain how you can set the default browser on a Debian OS using the command line. We will use the update-alternatives utility to update one of the installed browsers as a default. It can be very helpful for the users that are accessing remotely and have only the command line access.
We have used Debian 10 OS for describing the procedure mentioned in this article.
How to set default Browser with the command line?
To open the command line or Terminal application in a Debian 10 OS, go to the Activities tab on the top left corner of your desktop. Then in the search bar, type terminal. when the Terminal icon appears, click on it to open.
Now in the Terminal, execute the following command as sudo:
$ sudo update-alternatives –config x-www-browser
You will see output similar to below. From the output, you can see the list of installed browsers in your system. The (*) symbol before the selection numbers indicates the current default browser.
To change the default browser, select a number against a web browser and press Enter to set it as a new default option.
The above list by default contains browsers from the /usr/bin directory. However, if browsers are located at some other location, they can be added to the alternatives list.
For instance, you have a chromium-browser located at /snap/bin instead of /usr/bin directory. Using the below command, you can set it as a default browser and also add it to the update-alternatives list for future use.
$ sudo update-alternatives --install /usr/bin/x-www-browser x-www-browser /snap/bin/chromium 200
That is all there is to it! I hope it will be helpful whenever you need to set a default browser in your system using the command line.