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:
PDF:
Images:
Texts:
Video/Music:
If you want the program to be run detached from the terminal then this is the way that I prefer doing it:
For example:
Remember that you can always redirect the outputs as usual, e.g. :