Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

The answers in the previous question did not help - Can't edit /etc/profile on my mac

I want to edit /etc/profile but I can't, even when I open it with sudo. I manually changed the permissions on the file with

sudo chmod u+w /etc/profile

And now I get a different error when I try to save the file. Instead of it telling me I don't have permission, the dialog simply says "The document 'profile' could not be saved." How can I change the file?

share|improve this question
    
What program are you using to edit the file via sudo? –  Kent Jun 13 '13 at 23:36
    
I am using TextEdit –  Eric Baldwin Jun 13 '13 at 23:42
    
You should use an editor inside the Terminal, such as emacs, vi, or pico. Running a window app such as TextEdit as sudo does not work. (Specifically, you should run "sudo emacs /etc/profile" or "sudo vi /etc/profile") –  Kent Jun 13 '13 at 23:48
    
that worked, thanks –  Eric Baldwin Jun 13 '13 at 23:53
    
u+w isn't what you want... you aren't the user... you want to give group/other write if you are going that route. sudo chmod go+w /etc/profile. –  demure Jun 14 '13 at 1:21

1 Answer 1

It should work if you run the executable as root:

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

If you run sudo chmod u+w /etc/profile and open /etc/profile normally with TextEdit, TextEdit shows an error because it doesn't have write permission to /private/etc/. TextEdit has also required write permission to the containing directory since 10.7, which might have something to do with auto-save or sandboxing.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.