How can I launch a GUI app in Applications folder from command line?

Solution 1:

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

Solution 2:

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.