How to open a specific application like macOS `open -a`?

The name of the pictureThe name of the pictureThe name of the pictureClash 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.










share|improve this question









New contributor




mmorin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.



















  • 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




    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




    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




    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















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.










share|improve this question









New contributor




mmorin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.



















  • 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




    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




    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




    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













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.










share|improve this question









New contributor




mmorin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











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






share|improve this question









New contributor




mmorin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




mmorin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited Oct 5 at 1:26









muru

131k19276473




131k19276473






New contributor




mmorin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked Oct 4 at 11:11









mmorin

1646




1646




New contributor




mmorin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





mmorin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






mmorin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











  • 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




    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




    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




    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

















  • 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




    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




    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




    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
















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











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 &





share|improve this answer


















  • 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 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




    @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




    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











Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "89"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);






mmorin is a new contributor. Be nice, and check out our Code of Conduct.









 

draft saved


draft discarded


















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






























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 &





share|improve this answer


















  • 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 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




    @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




    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















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 &





share|improve this answer


















  • 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 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




    @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




    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













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 &





share|improve this 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 &






share|improve this answer














share|improve this answer



share|improve this answer








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 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




    @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




    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













  • 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 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




    @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




    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








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











mmorin is a new contributor. Be nice, and check out our Code of Conduct.









 

draft saved


draft discarded


















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.













 


draft saved


draft discarded














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













































































Popular posts from this blog

How to check contact read email or not when send email to Individual?

Bahrain

Postfix configuration issue with fips on centos 7; mailgun relay