You may have several web browsers installed on our Ubuntu that we want to use for different browsing preferences. However, there is always one favorite browser that we want to use for regular Internet usage 90% of the time. It is best to set this browser as the default browser for your Ubuntu system. This default browser is the one that opens links you click on in any Ubuntu application, and it opens when you type x-www-browser in your Ubuntu command line.

Setting the default web browser from the Ubuntu user interface is very simple. You just need to open the Preferences utility, go to the Details tab, click on Default Applications, and then select your preferred web browser from the Web drop-down menu.

Ubuntu default Browser settings

However, this article 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 browser. It’s good to learn this trick since we don’t always have the UI available. For example, a server administrator or a remote user can easily access the command line and make configurations on the target computer.

We have tested the commands and procedures mentioned in this article on various Unbuntu systems from version 18.04 to Ubuntu 22.04. We use the Terminal application to access the Ubuntu command line. You can open it via the System Dash or the key combination Ctrl+Alt+T.

How to set the 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.

Use update-alternatives command to set default browser

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

Set default Browser to Chromium

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 add 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.

Set Your Favorite Browser as Default through Ubuntu Command Line