Categories: DebianLinuxShell

How to set the default browser on Debian trough the command line

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.

Karim Buzdar

About the Author: Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications. As an IT engineer and technical author, he writes for various web sites. You can reach Karim on LinkedIn

Recent Posts

How to Install Magento 2 on AlmaLinux

Magento is a free and open-source e-commerce platform written in PHP. It is simple, easy…

1 year ago

How to Install ISPConfig Hosting Control Panel with Apache Web Server on Ubuntu 24.04

ISPConfig is an open-source control panel that allows users to manage multiple servers from a…

1 year ago

How to Test your Email Server (SMTP) Using the Telnet Command

As a Linux administrator, you may find it necessary to troubleshoot or test your Simple…

1 year ago

Managing Network Interfaces and Settings on Ubuntu 24.04 with nmcli

Ubuntu 24.04, like many modern Linux distributions, relies on the NetworkManager for managing network connections.…

2 years ago

Using Restic Backup on Ubuntu 24.04

Restic is a modern, open-source backup program designed for efficiency, security, and simplicity. It enables…

2 years ago

Installing phpMyAdmin on Rocky Linux 9 and Securing it with Let’s Encrypt SSL

phpMyAdmin is a popular free tool written in PHP intended to administer MySQL and MariaDB…

2 years ago