I would like to launch a GUI app that is in the Applications folder from the command line as opposed to clicking the icon in the Finder or in the Dock. The reason I want that is to be able to launch it as root using sudo as opposed to launching it as my default user.

When I went into the Applications, this is what it looked like:

/Applications/IntelliJ IDEA 13 CE.app@16:16:42>ls -la
total 40
drwxr-xr-x@ 10 myuser  admin    340 Dec 17 14:07 .
drwxrwxr-x+ 68 root           admin   2312 Jan 20 18:00 ..
drwxr-xr-x@  6 myuser  admin    204 Dec 17 14:08 Contents
-rw-r--r--@  1 myuser  admin  11358 Dec 17 14:06 LICENSE.txt
-rw-r--r--@  1 myuser  admin    127 Dec 17 14:06 NOTICE.txt
drwxr-xr-x@ 14 myuser  admin    476 Dec 17 14:09 bin
-rw-r--r--@  1 myuser  admin     10 Dec 17 14:01 build.txt
drwxr-xr-x@ 85 myuser  admin   2890 Dec 17 14:06 lib
drwxr-xr-x@ 29 myuser  admin    986 Dec 17 14:06 license
drwxr-xr-x@ 30 myuser  admin   1020 Dec 17 14:06 plugins

Funny thing is, in the Finder, IntelliJ IDEA 13 CE shows as a clickable icon which launches the app. But at the terminal level, it is actually a directory with contents I do not know how to navigate and manipulate to emulate a GUI click.


2 Answers 2


Simply use open:

open "/Applications/IntelliJ IDEA 13 CE.app"
open -a "IntelliJ IDEA 13 CE"

However, prepending sudo isn't enough to run as root. You'll need to run the actual binary:

sudo /Applications/ApplicationName.app/Contents/MacOS/ApplicationName
  • 1
    If you use the -a flag for the open command you don't need the path.
    – Ɱark Ƭ
    Jan 29, 2014 at 21:42
  • Yes, but giving the full path will always work regardless of where the app is located. Either way, I've added it.
    – grg
    Jan 29, 2014 at 21:45
  • I didn't have to use open.
    – amphibient
    Jan 29, 2014 at 21:50
  • I've never had the -a flag fail. Apps don't have to be located in /Applications for it to work. I can open stuff I've written that is buried somewhere in ~/Library/ without a problem. The only issue is if there is more than one copy of an app then I'm not sure which one will open.
    – Ɱark Ƭ
    Jan 29, 2014 at 21:50
  • 1
    Just a warning that some apps don't like their executable run directly without passing them some options on the command line. Isn't there a plist somewhere that defines the options that get passed to the executable when it is run as an app? Jan 29, 2014 at 23:23

Just 'cd' into the application bundle, then into the Contents folder, and then into the MacOS folder. There should be an executable file in there which you can run normally. If there are multiple executable files in there, you could look at the Contents/Info.plist file inside the application bundle, and look for the entry CFBundleExecutable, which indicates the executable file that is launched when you double-click the application bundle in Finder.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .