Home Linux Commandline Tips How to Open a URL in the Web Browser from Linux Terminal

How to Open a URL in the Web Browser from Linux Terminal

Flexibility is an underrated attribute overlooked by many users of the Linux operating system. Being a flexible Linux user implies that you can launch most; if not all, of your user and system applications from the command line interface without having to navigate and search for them from the system GUI applications’ menu.

Also, the flexibility of your Linux OS user experience not only applies to system-based applications like installed apps but also to non-system-based applications like web apps that require a URL for access.

[ You might also like: How to Get the Number of Processors/Cores in Linux ]

When working with Linux, you don’t necessarily need to open a browser application before you can access targeted URLs associated with specific websites.

This article will walk us through various ways (commands) of opening a URL on a default browser application from the terminal.

1. The xdg-open Command

As per the Linux man page, the xdg-open command opens a file or URL via the user’s preferred/default file application or browser application.

Its usage can be demonstrated via the following command syntax:

$ xdg-open TARGETED_WEB_URL

For instance, to open the LinuxShellTips home page from the Linux command-line interface, we will execute the following command.

$ xdg-open 'http://ubuntumint.com'
Opens File or URL in Linux Commandline
Opens File or URL in Linux Commandline

The execution of the xdg-open command will open the specified URL on your default web browser application.

Opens URL in Web Browser
Opens URL in Web Browser

2. The sensible-browser Command

As per the Linux operating system man pages, the sensible-browser command can be used to execute sensible decisions regarding a default web browser application that can be used to open a targeted web URL.

Its implementation can be referenced from the following command syntax:

$ sensible-browser URL_OF_TARGETED_WEB_PAGE

For instance, we can access a random LinuxShellTips website URL in the following manner:

$ sensible-browser 'http://ubuntumint.com/ssh-passwordless-login-almalinux'
sensible-browser Command Opens URL
sensible-browser Command Opens URL

The execution of the sensible-browser command should redirect us to the specified URL on the default web browser.

Opens Webpage in Browser
Opens Webpage in Browser

The use of the sensible-browser command is fully supported in Debian-based Linux operating system distributions like Linux Mint and Ubuntu.

3. The x-www-browser Command

Even though the x-www-browser command might not exist in the Linux man-pages ($ man x-www-browser) of the Linux operating system distribution you are using, it is equally effective in redirecting a user to a specified web URL on their default web browser.

Its command syntax can be represented in the following manner:

$ x-www-browser URL_OF_TARGETED_WEB_PAGE

For demonstration, let us try to access another random web page on the LinuxShellTips website.

$ x-www-browser 'http://ubuntumint.com/download-files-remote-linux-servers'
x-www-browser Command
x-www-browser Command

The execution of the x-www-browser command should swiftly redirect you to a web browser with a display of the specified web page URL.

Opens Webpage in Browser
Opens Webpage in Browser

4. Alternative Commands to Open URL

You could alternatively use your browser name as part of the Linux command for opening the web page URL you are targeting:

For Firefox web browser:

$ firefox http://google.com

For Google Chrome web browser:

$ google-chrome http://google.com 

Despite the error messages on the terminal on executing these alternative commands, your specified web URL should open without any issues.

Open URL from Linux Commandline
Open URL from Linux Commandline

You now know some cool tweaks on opening web URLs on the Linux command-line without directly going to the web browser’s GUI app.

Ravi Saive
I am an Experienced GNU/Linux expert and a full-stack software developer with over a decade in the field of Linux and Open Source technologies. Founder of TecMint.com, LinuxShellTips.com, and Fossmint.com. Over 150+ million people visited my websites.

Each tutorial at UbuntuMint is created by a team of experienced writers so that it meets our high-quality standards.

Was this article helpful? Please add a comment to show your appreciation and support.

Got something to say? Join the discussion.

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published or shared. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.