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. – JoL Oct 04 '18 at 15:26bash: firefox: command not found. Same error withFirefoxas program name. – miguelmorin Oct 04 '18 at 16:36bashworks 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-binfrom the command line.Firefox.appis 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.openis a way to "run" the special folder from the command line. – chepner Oct 04 '18 at 18:53bashworks differently: firefox is installed as an OS X application (Firefox.app) and is not on the regular PATH. Another reason to useopen -ais that it properly backgrounds the application it launches, instead of waiting on it until it exits. – alexis Oct 04 '18 at 18:54&– Dev Oct 04 '18 at 20:00