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.
open -a Firefox http://www.wikipedia.org
? Can't you dofirefox http://www.wikipedia.org
? It seems like a useless feature ofopen
, when opening programs is the very point ofbash
.bash: firefox: command not found
. Same error withFirefox
as program name.bash
works exactly the same; it's Firefox that is installed differently than it is on Ubuntu. On macOS, you could, for instance, run/Applications/Firefox.app/Contents/MacOS/firefox-bin
from the command line.Firefox.app
is a special kind of folder that contains not just the executable, but files that in Linux might be scattered about in various/usr/bin/
,/usr/lib
,/etc
, etc. directories. The Finder knows how to run the actual application when you, for instance, double-click onFirefox.app
.open
is a way to "run" the special folder from the command line.bash
works differently: firefox is installed as an OS X application (Firefox.app
) and is not on the regular PATH. Another reason to useopen -a
is that it properly backgrounds the application it launches, instead of waiting on it until it exits.&