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://linuxshelltips.com'
The execution of the xdg-open command will open the specified URL on your default web browser application.
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://linuxshelltips.com/ssh-passwordless-login-almalinux'
The execution of the sensible-browser command should redirect us to the specified URL on the default web 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://linuxshelltips.com/download-files-remote-linux-servers'
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.
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.
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.