Set Default Browser Ubuntu Command Line - LinuxConfig

Setting the Default Web Browser in Ubuntu via Command Line
Ubuntu Linux is configured by default to automatically open web links within the appropriate browser when clicked in a graphical user interface (GUI) application like Gnome. While the default browser can be easily modified through the system’s graphical tools, utilizing the command line interface offers a convenient alternative.
This method is particularly useful when remotely managing a system, where GUI access may not be available.
Using the update-alternatives Command
The update-alternatives command is the tool used to manage default applications in Ubuntu. It allows you to select from multiple installed programs that can fulfill the same function.
To modify the default web browser, execute the following command in your terminal:
sudo update-alternatives --config x-www-browser
The output will display a list of available browsers registered as alternatives for handling web links.
You might observe a display resembling the following example, which indicates that Konqueror is currently set as the default browser in this instance:
$ sudo update-alternatives --config x-www-browserThere are 2 alternatives which provide `x-www-browser'.
Selection Alternative
-----------------------------------------------
1 /usr/bin/firefox
*+ 2 /usr/bin/konqueror
Press enter to keep the default[*], or type selection number:
Selecting Your Preferred Browser
To designate a different browser as the default, simply enter the corresponding number from the list and press Enter.
For example, to set Firefox as the default browser, input '1' and confirm with Enter.
This change will then be reflected system-wide, ensuring that web links are opened with your chosen browser.