Method 1
Suppose your browser is Firefox and your script urlopener
is
#!/bin/bash
firefox "$1"
Run it like
./urlopener "https://google.com"
Sidenote
Replace firefox
with your browser's executable file name.
Method 2
As [ @sato-katsura ] mentioned in the comment, in *nixes you can use an application called xdg-open
. For example,
xdg-open https://google.com
The manual for xdg-open
says
xdg-open - opens a file or URL in the user's preferred application
xdg-open opens a file or URL in the user's preferred application. If a
URL is provided the URL will be opened in the user's preferred web
browser.
If a file is provided the file will be opened in the
preferred application for files of that type. xdg-open supports file,
ftp, http and https URLs.
As [ this ] answer points out you could change your preferred browser using say:
xdg-settings set default-web-browser firefox.desktop
or
xdg-settings set default-web-browser chromium-browser.desktop
webbrowser.open
. In a cli environment, you can just dopython -m webbrowser https://google.com
, provided you have python installed (most linux distributions do)open http://localhost:9000
open
command is mac-only. It for sure doesn't work on ubuntu.