How to open a specific application like macOS `open -a`?
Clash Royale CLAN TAG#URR8PPP
up vote
11
down vote
favorite
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.
command-line
New contributor
 |Â
show 2 more comments
up vote
11
down vote
favorite
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.
command-line
New contributor
I've never used a Mac, so can you tell me why you'd useopen -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 4 at 15:26
1
Bash on macOS works differently, e.g. your command gives the errorbash: firefox: command not found
. Same error withFirefox
as program name.
â mmorin
Oct 4 at 16:36
3
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.
â chepner
Oct 4 at 18:53
4
It's not thatbash
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.
â alexis
Oct 4 at 18:54
askubuntu.com/a/15356&
â Dev
Oct 4 at 20:00
 |Â
show 2 more comments
up vote
11
down vote
favorite
up vote
11
down vote
favorite
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.
command-line
New contributor
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.
command-line
command-line
New contributor
New contributor
edited Oct 5 at 1:26
muru
131k19276473
131k19276473
New contributor
asked Oct 4 at 11:11
mmorin
1646
1646
New contributor
New contributor
I've never used a Mac, so can you tell me why you'd useopen -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 4 at 15:26
1
Bash on macOS works differently, e.g. your command gives the errorbash: firefox: command not found
. Same error withFirefox
as program name.
â mmorin
Oct 4 at 16:36
3
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.
â chepner
Oct 4 at 18:53
4
It's not thatbash
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.
â alexis
Oct 4 at 18:54
askubuntu.com/a/15356&
â Dev
Oct 4 at 20:00
 |Â
show 2 more comments
I've never used a Mac, so can you tell me why you'd useopen -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 4 at 15:26
1
Bash on macOS works differently, e.g. your command gives the errorbash: firefox: command not found
. Same error withFirefox
as program name.
â mmorin
Oct 4 at 16:36
3
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.
â chepner
Oct 4 at 18:53
4
It's not thatbash
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.
â alexis
Oct 4 at 18:54
askubuntu.com/a/15356&
â Dev
Oct 4 at 20:00
I've never used a Mac, so can you tell me why you'd use
open -a Firefox http://www.wikipedia.org
? Can't you do firefox http://www.wikipedia.org
? It seems like a useless feature of open
, when opening programs is the very point of bash
.â JoL
Oct 4 at 15:26
I've never used a Mac, so can you tell me why you'd use
open -a Firefox http://www.wikipedia.org
? Can't you do firefox http://www.wikipedia.org
? It seems like a useless feature of open
, when opening programs is the very point of bash
.â JoL
Oct 4 at 15:26
1
1
Bash on macOS works differently, e.g. your command gives the error
bash: firefox: command not found
. Same error with Firefox
as program name.â mmorin
Oct 4 at 16:36
Bash on macOS works differently, e.g. your command gives the error
bash: firefox: command not found
. Same error with Firefox
as program name.â mmorin
Oct 4 at 16:36
3
3
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 on Firefox.app
. open
is a way to "run" the special folder from the command line.â chepner
Oct 4 at 18:53
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 on Firefox.app
. open
is a way to "run" the special folder from the command line.â chepner
Oct 4 at 18:53
4
4
It's not that
bash
works differently: firefox is installed as an OS X application (Firefox.app
) and is not on the regular PATH. Another reason to use open -a
is that it properly backgrounds the application it launches, instead of waiting on it until it exits.â alexis
Oct 4 at 18:54
It's not that
bash
works differently: firefox is installed as an OS X application (Firefox.app
) and is not on the regular PATH. Another reason to use open -a
is that it properly backgrounds the application it launches, instead of waiting on it until it exits.â alexis
Oct 4 at 18:54
askubuntu.com/a/15356
&
â Dev
Oct 4 at 20:00
askubuntu.com/a/15356
&
â Dev
Oct 4 at 20:00
 |Â
show 2 more comments
1 Answer
1
active
oldest
votes
up vote
10
down vote
accepted
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 &
2
eog picture.jpg
for images too if you have gnome-desktop installed :)
â Videonauth
Oct 4 at 11:19
1
@Videonauth Yeah, or any other kind of tools ;)
â Ravexina
Oct 4 at 11:20
2
@BaptisteCandellier I don't get the point of callingopen
to call another program. Why not just call the other program directly? What usefulness doesopen
add? This answer reflects the natural thing to do to open specific applications.
â JoL
Oct 4 at 15:35
1
@BaptisteCandellier I agree, andopen
on macOS works both for opening files and folders in the default application and in specific applications. It seems the originalbash
went on a different path withxdg-open
for files and the application names for the rest.
â mmorin
Oct 4 at 17:00
2
Another thing that is different aboutopen
in MacOS is that it launches the application detached from the console it's run from, i.e. if the console closes, the app will stay on. On Ubuntu one needs to use thenohup
command to get the same behaviour. (since prefixing each command with nohup and redirecting output for each command you run gets tiring, it may make more sense to define a custom shortcut)
â undercat
Oct 5 at 4:20
 |Â
show 8 more comments
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
10
down vote
accepted
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 &
2
eog picture.jpg
for images too if you have gnome-desktop installed :)
â Videonauth
Oct 4 at 11:19
1
@Videonauth Yeah, or any other kind of tools ;)
â Ravexina
Oct 4 at 11:20
2
@BaptisteCandellier I don't get the point of callingopen
to call another program. Why not just call the other program directly? What usefulness doesopen
add? This answer reflects the natural thing to do to open specific applications.
â JoL
Oct 4 at 15:35
1
@BaptisteCandellier I agree, andopen
on macOS works both for opening files and folders in the default application and in specific applications. It seems the originalbash
went on a different path withxdg-open
for files and the application names for the rest.
â mmorin
Oct 4 at 17:00
2
Another thing that is different aboutopen
in MacOS is that it launches the application detached from the console it's run from, i.e. if the console closes, the app will stay on. On Ubuntu one needs to use thenohup
command to get the same behaviour. (since prefixing each command with nohup and redirecting output for each command you run gets tiring, it may make more sense to define a custom shortcut)
â undercat
Oct 5 at 4:20
 |Â
show 8 more comments
up vote
10
down vote
accepted
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 &
2
eog picture.jpg
for images too if you have gnome-desktop installed :)
â Videonauth
Oct 4 at 11:19
1
@Videonauth Yeah, or any other kind of tools ;)
â Ravexina
Oct 4 at 11:20
2
@BaptisteCandellier I don't get the point of callingopen
to call another program. Why not just call the other program directly? What usefulness doesopen
add? This answer reflects the natural thing to do to open specific applications.
â JoL
Oct 4 at 15:35
1
@BaptisteCandellier I agree, andopen
on macOS works both for opening files and folders in the default application and in specific applications. It seems the originalbash
went on a different path withxdg-open
for files and the application names for the rest.
â mmorin
Oct 4 at 17:00
2
Another thing that is different aboutopen
in MacOS is that it launches the application detached from the console it's run from, i.e. if the console closes, the app will stay on. On Ubuntu one needs to use thenohup
command to get the same behaviour. (since prefixing each command with nohup and redirecting output for each command you run gets tiring, it may make more sense to define a custom shortcut)
â undercat
Oct 5 at 4:20
 |Â
show 8 more comments
up vote
10
down vote
accepted
up vote
10
down vote
accepted
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 &
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 &
edited 2 days ago
answered Oct 4 at 11:16
Ravexina
29.2k147199
29.2k147199
2
eog picture.jpg
for images too if you have gnome-desktop installed :)
â Videonauth
Oct 4 at 11:19
1
@Videonauth Yeah, or any other kind of tools ;)
â Ravexina
Oct 4 at 11:20
2
@BaptisteCandellier I don't get the point of callingopen
to call another program. Why not just call the other program directly? What usefulness doesopen
add? This answer reflects the natural thing to do to open specific applications.
â JoL
Oct 4 at 15:35
1
@BaptisteCandellier I agree, andopen
on macOS works both for opening files and folders in the default application and in specific applications. It seems the originalbash
went on a different path withxdg-open
for files and the application names for the rest.
â mmorin
Oct 4 at 17:00
2
Another thing that is different aboutopen
in MacOS is that it launches the application detached from the console it's run from, i.e. if the console closes, the app will stay on. On Ubuntu one needs to use thenohup
command to get the same behaviour. (since prefixing each command with nohup and redirecting output for each command you run gets tiring, it may make more sense to define a custom shortcut)
â undercat
Oct 5 at 4:20
 |Â
show 8 more comments
2
eog picture.jpg
for images too if you have gnome-desktop installed :)
â Videonauth
Oct 4 at 11:19
1
@Videonauth Yeah, or any other kind of tools ;)
â Ravexina
Oct 4 at 11:20
2
@BaptisteCandellier I don't get the point of callingopen
to call another program. Why not just call the other program directly? What usefulness doesopen
add? This answer reflects the natural thing to do to open specific applications.
â JoL
Oct 4 at 15:35
1
@BaptisteCandellier I agree, andopen
on macOS works both for opening files and folders in the default application and in specific applications. It seems the originalbash
went on a different path withxdg-open
for files and the application names for the rest.
â mmorin
Oct 4 at 17:00
2
Another thing that is different aboutopen
in MacOS is that it launches the application detached from the console it's run from, i.e. if the console closes, the app will stay on. On Ubuntu one needs to use thenohup
command to get the same behaviour. (since prefixing each command with nohup and redirecting output for each command you run gets tiring, it may make more sense to define a custom shortcut)
â undercat
Oct 5 at 4:20
2
2
eog picture.jpg
for images too if you have gnome-desktop installed :)â Videonauth
Oct 4 at 11:19
eog picture.jpg
for images too if you have gnome-desktop installed :)â Videonauth
Oct 4 at 11:19
1
1
@Videonauth Yeah, or any other kind of tools ;)
â Ravexina
Oct 4 at 11:20
@Videonauth Yeah, or any other kind of tools ;)
â Ravexina
Oct 4 at 11:20
2
2
@BaptisteCandellier I don't get the point of calling
open
to call another program. Why not just call the other program directly? What usefulness does open
add? This answer reflects the natural thing to do to open specific applications.â JoL
Oct 4 at 15:35
@BaptisteCandellier I don't get the point of calling
open
to call another program. Why not just call the other program directly? What usefulness does open
add? This answer reflects the natural thing to do to open specific applications.â JoL
Oct 4 at 15:35
1
1
@BaptisteCandellier I agree, and
open
on macOS works both for opening files and folders in the default application and in specific applications. It seems the original bash
went on a different path with xdg-open
for files and the application names for the rest.â mmorin
Oct 4 at 17:00
@BaptisteCandellier I agree, and
open
on macOS works both for opening files and folders in the default application and in specific applications. It seems the original bash
went on a different path with xdg-open
for files and the application names for the rest.â mmorin
Oct 4 at 17:00
2
2
Another thing that is different about
open
in MacOS is that it launches the application detached from the console it's run from, i.e. if the console closes, the app will stay on. On Ubuntu one needs to use the nohup
command to get the same behaviour. (since prefixing each command with nohup and redirecting output for each command you run gets tiring, it may make more sense to define a custom shortcut)â undercat
Oct 5 at 4:20
Another thing that is different about
open
in MacOS is that it launches the application detached from the console it's run from, i.e. if the console closes, the app will stay on. On Ubuntu one needs to use the nohup
command to get the same behaviour. (since prefixing each command with nohup and redirecting output for each command you run gets tiring, it may make more sense to define a custom shortcut)â undercat
Oct 5 at 4:20
 |Â
show 8 more comments
mmorin is a new contributor. Be nice, and check out our Code of Conduct.
mmorin is a new contributor. Be nice, and check out our Code of Conduct.
mmorin is a new contributor. Be nice, and check out our Code of Conduct.
mmorin is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1080846%2fhow-to-open-a-specific-application-like-macos-open-a%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
I've never used a Mac, so can you tell me why you'd use
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 4 at 15:26
1
Bash on macOS works differently, e.g. your command gives the error
bash: firefox: command not found
. Same error withFirefox
as program name.â mmorin
Oct 4 at 16:36
3
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.â chepner
Oct 4 at 18:53
4
It's not that
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.â alexis
Oct 4 at 18:54
askubuntu.com/a/15356
&
â Dev
Oct 4 at 20:00