How to open default browser from command line Linux

7

On Ubuntu, you might have several web browsers installed, which are utilized according to your browsing preferences. Although, we all have a most favorite web browser to use 90% of the internet every day. In Linux, it is preferred to state the best browser as the default browser. This default browser will also allow you to open links from the terminal.

Checking default web browser:

To set, change or view the default browser through a terminal or user interface is simple yet straightforward.
Write out the below-given command to know the default browser of your Linux system.

$ xdg-settings get default-web-browser

You can look into the list of other default applications, including your default browser. For performing this, there are two methods, In the first method, you can use the below-given command, and it will redirect you to the Default Application windows.

$ gnome-control-center default-applications

how to open default browser from command line linux How to open default browser from command line Linux 1623705378 246 How to open default browser from command line Linux

Searching “Default Applications” in the activities is considered as the second method.

how to open default browser from command line linux How to open default browser from command line Linux 1623705380 298 How to open default browser from command line Linux

The highlighted web browser in the “Web” option is already picked as the default web browser.

how to open default browser from command line linux How to open default browser from command line Linux 1623705380 103 How to open default browser from command line Linux

You can also check out the list of other available alternatives for browsing the web on your system.

$ sudo update-alternatives –config x-www-browser

how to open default browser from command line linux How to open default browser from command line Linux 1623705381 0 How to open default browser from command line Linux

The output declares that “Google Chrome” also exists as a web browser on our Ubuntu.

Opening default web browser from the command line:

Now, we will try to open the google instance in the default web browser, which is “firefox” in our case. Utilize the below-given command in your terminal if you want to do so.

$ xdg-open https://www.google.co.uk

how to open default browser from command line linux How to open default browser from command line Linux 1623705382 951 How to open default browser from command line Linux

Here, you can see terminal command execution successfully open a google instance in our default web browser.

how to open default browser from command line linux How to open default browser from command line Linux 1623705382 955 How to open default browser from command line Linux

Changing default web browser:

For setting any other browser as the default one, you have to execute the “xdg” settings command with the browser name at the end. We will set “Google Chrome” as the default browser on our Linux system in the following example.

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

how to open default browser from command line linux How to open default browser from command line Linux 1623705383 926 How to open default browser from command line Linux

Again, open any web instance by specifying its URL in the “xdg” open command. Furthermore, we have chosen “Google” for the testing.

$ xdg-open https://www.google.co.uk

how to open default browser from command line linux How to open default browser from command line Linux 1623705383 853 How to open default browser from command line Linux

The output states that we are successful in setting “Google Chrome” as your default browser.

how to open default browser from command line linux How to open default browser from command line Linux 1623705384 316 How to open default browser from command line Linux

Conclusion:

As Linux users, we all have various installed web browsers, which we use according to our web preferences. Still, there exists a possibility of 90% using a single web browser for browsing activities which turns to be our default web browser. In this article, we have seen opening the default browser for any web instance from the command line. Furthermore, the procedure of viewing and setting any other alternatives to your default browser is also provided.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More