set default web browser feature image

How to Set Default Web Browser using Terminal in Linux?

Introduction

Linux provides users with various options to customize their experience. One such customization is setting the default web browser. In this article, we will explore how to set the default web browser using the terminal in Linux. We will discuss different methods that cater to different Linux distributions.

Set Default Web Browser using Terminal in Linux:

Setting a default browser is very easy in most Operating Systems, and most modernized browsers will ask to set it as default browser by default once you install the Browser. But setting a Default browser in Linux using cmd is a little tricky, Follow the below-mentioned steps to Set the Default Web Browser using the terminal command.

Method 1: Ubuntu and Debian based systems

If you are using an Ubuntu or Debian-based system, you can use the update-alternatives command to set the default web browser.

Step 1: Open the Terminal

To open the terminal, you can use the shortcut Ctrl+Alt+T or search for Terminal in the applications menu.

Step 2: List available web browsers

In the terminal, enter the following command to list the available web browsers:

sudo update-alternatives --list x-www-browser

This will display a list of installed web browsers on your system. Note down the desired browser from the list.

Step 3: Set the default web browser

Enter the following command in the terminal, replacing browser_path with the path of the desired browser from the previous step:

sudo update-alternatives --set x-www-browser browser_path

For example, if you want to set Google Chrome as the default browser, the command would look like:

sudo update-alternatives --set x-www-browser /usr/bin/google-chrome-stable

Note: I conducted tests using these commands after installing various major web browsers. However, it appears that these commands are only listing Firefox and Chrome, despite having installed Opera and other web browsers.

If you want to set a Default browser in Ubuntu, Just Launch the Web browser that you want to set it has the default browser, and you’ll receive a notification or pop-up showing Set as default. click on it and make it has default browser.

How to Change the Default Web Browser in Ubuntu?

To Change the Default Web Browser in Ubuntu follow the below-mentioned steps.

Open Ubuntu Settings, you can find the Settings (Gear icon) from the left-hand dock or click on Show Applications from the bottom left corner and search for Settings.

Once you open Ubuntu Settings, from the left-hand side click on the Default Applications tab, and from the right-hand side click on the web drop-down menu and choose your favorite web browser.

That’s it, you have successfully set the default web browser.

Method 2: Fedora and CentOS based systems

On Fedora and CentOS based systems, the update-alternatives command is not available. However, you can use the alternatives command to achieve the same result.

Step 1: Open the Terminal

Open the terminal using the shortcut Ctrl+Alt+T or by searching for Terminal in the applications menu.

Step 2: List available web browsers

Enter the following command in the terminal to list the available web browsers:

alternatives --list | grep x-www-browser

The command will display a list of installed web browsers. Note down the desired browser from the list.

Step 3: Set the default web browser

Enter the following command in the terminal, replacing browser_path with the path of the desired browser:

sudo alternatives --set x-www-browser browser_path

For example, if you want to set Mozilla Firefox as the default browser, the command would look like:

sudo alternatives --set x-www-browser /usr/bin/firefox

Method 3: Arch Linux based systems

For Arch Linux based systems, you can use the xdg-settings command to set the default web browser.

Step 1: Open the Terminal

Open the terminal by using the shortcut Ctrl+Alt+T or through the applications menu.

Step 2: List available web browsers

Enter the following command in the terminal to list the available web browsers:

xdg-settings get default-web-browser

This will show the default web browser currently set on your system.

Step 3: Set the default web browser

Enter the following command in the terminal, replacing browser.desktop with the desired browser’s `.desktop` file name:

xdg-settings set default-web-browser browser.desktop

For example, to set Google Chrome as the default browser, the command would be:

xdg-settings set default-web-browser google-chrome.desktop

Conclusion

Setting the default web browser using the terminal in Linux provides a convenient way to personalize your browsing experience. Whether you are using Ubuntu, Fedora, CentOS, or Arch Linux, the methods discussed in this article will help you easily set your preferred browser as the default.

Read Also:

How to change the MAC screenshot default format using Terminal?

How to Install Any Browser Using Terminal in Windows 11?

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top