Launch GUI programs as root

Apr 01, '03 10:12:00AM

Contributed by: NeuralNet03

I was in the macosxhints chat channel, and someone asked about launching a OS X app as root without logging out, and without using Pseudo (which is a handy app, BTW). We came up with a fairly simple procedure for doing in the Terminal what Pseudo does normally on its own:

  sudo path/to/application/Contents/MacOS/app_name &
For example:
  sudo /Applications/TextEdit/Contents/MacOS/TextEdit &
That will launch the TextEdit program as root, and the ampersand backgrounds the process so you can get your Terminal back. You will be prompted for your login password (as is standard sudo behavior), and then the app will launch with full root privileges.

[robg adds: I tested this with TextEdit and used it to edit the httpd.conf file. It let me modify the file and save the changes, which proves that TextEdit was running as root. Be careful with this, though, as there's no indication as to which apps you've launched as root, and you would not want to accidentally change a system file that you did not mean to modify!]

Comments (19)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20030330175504453