0

I am using Emacs 24.3 on Mac OS X 10.9.4 and I am trying to edit /etc/profile with that. It obviously does not work when starting the GUI version, but for some reason, it also does not work when starting it with sudo from the command line. When I run

sudo emacs /etc/profile

from the terminal, Emacs still complains that the file is in read-only mode and it cannot write it:

Buffer is read-only: #<buffer profile>

What am I doing wrong?

  • 2
    You had two questions in here. This site works better when there is only one question per question. That way, it's easier for other people to find solutions if they have the same problem. I've edited out your second question, but feel free to ask it separately. – nohillside Jul 30 '14 at 16:47
3

/etc/profile is set to read-only for all users, so just using sudo won't help.

What you can do:

  • run sudo emacs /etc/profile
  • type C-x C-q to toggle readonly mode within Emacs
  • edit whatever you want
  • type C-x C-s to save it

Alternatively you can run

EDITOR=emacs sudo -e /etc/profile

which automatically creates a temporary copy of the file you want to edit (which makes it a bit safer in case you want to cancel the update).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .