How to Run GUI Apps as root in Mac OS X
Those familiar with the command line know that running things with super user privileges is typically just a matter of using the sudo command. That still holds true with launching GUI apps into the OS X with root privileges, but it’s not just a matter of prepending sudo to the otherwise useful open command. because ‘open’ launches apps as the original user, with or without sudo. The solution instead is to use sudo pointing directly at the executable contained within a given applications package file.
Launching OS X GUI Apps as root user
The command syntax is as follows:
In most cases, that will be applications stored in the /Applications/ directory, and the executable is almost always stored in Package/Contents/MacOS/ as whatever the applications name is:
For example, this command runs the familiar TextEdit app as root:
To launch TextEdit as a background app, meaning it wont close if you close the terminal window, apply the -b flag to sudo:
sudo -b /Applications/TextEdit.app/Contents/MacOS/TextEdit
You can confirm the the application is running as root by using the ps command with grep, again using TextEdit as an example:
ps au|grep TextEdit
Alternatively, you can look at the OS X process management app Activity Monitor and find the application running there as ‘root’ user, as demonstrated in the screenshot up top and the short video below:
If you intend on running a particular app frequently as root, you might consider placing an alias in .bash_profile to shorten the command string.
Despite running as root, not all system files may be modifiable and some may be marked as “Locked” when opened in some apps like TextEdit. That issue can often be resolved by enabling the root user if you have’t done so yet, but not all apps will have that limitation. Nonetheless, for certain tasks like editing the hosts file you’re still better off sticking to the command line and a text based editor, or using an app like BBEdit or TextWrangler.Source: osxdaily.com