How to Run GUI Apps as root in Mac OS X

Feb 6, 2013 - 9 Comments

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.

GUI application running as root user in Mac OS X

Launching OS X GUI Apps as root user

The command syntax is as follows:

sudo /Path/To/Application/ApplicationName.app/Path/To/Executable

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:

sudo /Applications/ApplicationName.app/Contents/MacOS/ApplicationName

For example, this command runs the familiar TextEdit app as root:

sudo /Applications/TextEdit.app/Contents/MacOS/TextEdit

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

Launch a GUI application as root in Mac OS X

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.

Enjoy this tip? Subscribe to the OSXDaily newsletter to get more of our great Apple tips, tricks, and important news delivered to your inbox! Enter your email address below:

Related articles:

Posted by: William Pearson in Command Line, Mac OS X, Tips & Tricks

9 Comments

» Comments RSS Feed

  1. anon says:

    As always, giant caveat on using root for stuff. Be sure you know what you’re doing. Back up files before making major modifications.

  2. DG says:

    So why might one need to do this?

  3. John Blommers says:

    Simpler: sudo open /Applications/TextEdit.app

  4. Lester says:

    sudu command is not for root, sudo is for admin.
    su is for root.

    Big difference,

    Open as admin:
    sudo open /Applications/TextEdit.app

    Open as root
    su open /Applications/TextEdit.app

    • dev_tty00 says:

      There is no admin user. sudo runs commands as root. Read the man page. Try this:

      sudo touch testfile

      You get:

      -rw-r–r– 1 root staff 0 Feb 7 11:30 testfile

      root created and owns the file.

    • parakeet says:

      su only works with root user enabled, sudo runs the command as root without root user account enabled. Fairly important difference, though su does work.

Leave a Reply

 

Shop for Apple & Mac Deals on Amazon.com

Subscribe to OSXDaily

Subscribe to RSS Subscribe to Twitter Feed Follow on Facebook Subscribe to eMail Updates