Ubuntu – How to open a specific application like macOS `open -a`

command line

On macOS in the default Terminal running bash, I can type:

open -a Firefox http://www.wikipedia.org

to open a URL with Firefox, or another browser. It also works to launch a program, e.g. open -a maps, and to open a file in the default program, e.g. open file.pdf.

How can I do the same on Ubuntu in the default GNOME Terminal also running bash? I know that I can open a file or URL with xdg-open /path/to/file, and I can open the default browser with sensible-browser. Does Ubuntu have a general command to open files, applications, or files in specific applications?

I am running bash on both machines, 3.2.57(1)-release on macOS and 4.4.19(1)-release on Ubuntu.

Best Answer

You can specifically use your desired program's name (if it's able to be used as a command line tool).

For example, urls:

firefox duckduckgo.com
chromium-browser askubuntu.com

PDF:

evince foo.pdf
okular bar.pdf

Images:

gpicview foo.png
feh bar.jpeg

Texts:

gedit foo.txt
mousepad /etc/config
leafpad bar.xml

Video/Music:

mpv  foo.mp3
vlc  bar.mp4

If you want the program to be run detached from the terminal then this is the way that I prefer doing it:

nohup program args &

For example:

nohup firefox askubuntu.com &

Remember that you can always redirect the outputs as usual, e.g. :

nohup firefox duckduckgo.com &> /dev/null &