Edit a file as root in OS X

To edit some config files that control how certain aspects of your OS X machine operate, (for example, your webserver) you need to be able to edit certain files as “root”. If you don’t know what “root” is, you shouldn’t be doing it, or you need to do a bit more research.

There are a number of ways to edit files as root.

  • login as root at the OS X login screen (if enabled), then open as usual. This method is not recommended
  • in the terminal open as root in pico by typing sudo pico path/filename
  • in the terminal open as root in Textedit by typing sudo open -a /Applications/TextEdit.app/ path/filename
  • open using a program like bbedit (powerful!) or textwrangler (free!) that simply ask for a password should you need root privilages to save a file. This is probably the easiest way.

One Response to “Edit a file as root in OS X”

  1. Steve Says:

    “…in the terminal open as root in Textedit by typing sudo open -a /Applications/TextEdit.app/ path/filename”

    Tried this and my httpd.conf is ‘read-only’ How do I overwrite what’s there?

Leave a Reply



Search WWW Search aliandcedar.com