I often need to edit special (i.e. system-owned) files, and until recently, the best method I could come up with was to find the file, give myself Read/Write access, edit it, then restore the previous rights. This becomes a little tiresome through the Get Info window, so I came up with a better solution. I use SubEthaEdit, but it should work with just about any editor (I do use pico when I am telnetting in from another computer, for example).
Add the following into your ~/.profile (bash) or wherever it belongs under another shell:
function edit
{
if test `echo $TERM_PROGRAM` == 'Apple_Terminal' ; then
open -a 'SubEthaEdit.app' "$*" &
else
pico "$*"
fi
}
function sedit
{
if test `echo $TERM_PROGRAM` == 'Apple_Terminal' ; then
sudo ~/Applications/SubEthaEdit.app/Contents/MacOS/SubEthaEdit "$*" &
else
sudo pico "$*"
fi
}
Now, start a new shell session, and use edit to edit files normally, and sedit to edit them as a super-user. You will need to be in the sudoers group (or whatever it's called) -- being an admin should suffice. I also set the background colours so that editing normally is blue, and sediting is reddy/orange, so I don't forget I am a super-user.
Mac OS X Hints
http://hints.macworld.com/article.php?story=20040831043957822