New To Mac-Forums?

Welcome to our community! Join the discussion today by registering your FREE account. If you have any problems with the registration process, please contact us!

Get your questions answered by community gurus • Advice and insight from world-class Apple enthusiasts • Exclusive access to members-only contests, giveaways and deals

Join today!

Start a Discussion

Mac-Forums Brief

Subscribe to Mac-Forums Brief to receive special offers from Mac-Forums partners and sponsors

Join the conversation RSS
OS X - Development and Darwin Discussion and questions about development for Mac OS X.

Open GUI applications as root

Post Reply New Thread Subscribe

Thread Tools
Posts: n/a

If you need to edit a root-owned system configuration file, it is possible to do so with a graphical text editor, if you so desire. In fact, any application can be opened as root [although why anyone would want to open as root is beyond me...] (This functionality is essentially what Brian Hill's utility Pseudo allows you to do:

First, a little background about the open command:

The command is simply open (which can also be used for opening directories). The most basic example is launching an application:
open /path/to/

More complex possibilities also exist:

open "/Volumes/Macintosh HD/somedoc.txt"
opens the document in the default application for its type (as determined by LaunchServices).

open /Applications/
opens that directory in the Finder.

open -a /Applications/ "/Volumes/Macintosh HD/somedoc.txt"
opens the document in the application specified (in this case, TextEdit).

open -e "/Volumes/Macintosh HD/somedoc.txt"
opens the document in TextEdit (the -e option specifies TextEdit).

opens the URL in the default browser (lynx, naturally *wink*)

open "file://localhost/Volumes/Macintosh HD/somedoc.txt"
opens the document in the default application for its type (as determined by LaunchServices).

open "file://localhost/Volumes/Macintosh HD/Applications/"
opens that directory in the Finder.

As you can see, open is a very versatile command. However, in the following post I will point at least one glaring limitation. Let the fun begin...
QUOTE Thanks
Posts: n/a

Launching Carbon applications with root privileges
Older Carbon applications have to be run via LaunchCFMApp because they are in the wrong binary format for Mac OS X, so LaunchCFMApp handles the necessary translation.

To launch a Carbon application directly (without using open), one has to actually run LaunchCFMApp, giving it the application as an argument:
/System/Library/Frameworks/Carbon.framework/Versions/Current/Support/LaunchCFMApp '/path/to/some/application'.

open can also be used to launch Carbon applications. open simulates a double click, hence the package name is given, rather than the full path to the executable. open's main advantage is in opening documents since it uses the Finder's 'open with' database of what applications open what documents, and in opening Carbon applications. Using open, most of the difficult work is done for you: open '/path/to/some/application'

To launch a Carbon application with root privileges, you have to prepend sudo -b to the first command above. Here is a specific example:
sudo -b /System/Library/Frameworks/Carbon.framework/Versions/Current/Support/LaunchCFMApp '/Applications/BBEdit Lite 6.1/BBEdit Lite 6.1 for OS X'

Launching Cocoa applications with root privileges
To run applications as root, we use sudo. However combining open and sudo in this form:
sudo open /path/to/
results in sudo running open as root, but open still opens the application as the original user!!!

Therefore, the longer method of specifying the full path name for Cocoa applications (not just to the .app package, but to the actual executable):
sudo "/Applications/"

(The -b flag can be specified to run appropriate applications in the background. You can't use & and sudo when an authentication password is required, necessitating the need for the -b flag.)
QUOTE Thanks

Post Reply New Thread Subscribe

« "Invisify" files and directories in the Finder | Mac Developers »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Starter
Last Post
Java From Terminal jdgti OS X - Development and Darwin 10 03-26-2005 07:16 PM
applications that open on start up ?? BenV OS X - Operating System 1 08-15-2004 03:30 PM
Root login problem in 10.3.3 azstech OS X - Operating System 6 04-28-2004 09:56 PM
Applications won't launch in Panther trinket OS X - Operating System 6 01-22-2004 09:45 PM
List your installed applications gatorparrots OS X - Development and Darwin 0 01-03-2003 12:23 AM

All times are GMT -4. The time now is 09:14 AM.

Powered by vBulletin
Copyright ©2000 - 2015, Jelsoft Enterprises Ltd.

Welcome to

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!

(4 digit year)

Already a member?