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?
Best Answer
/etc/profile
is set to read-only for all users, so just usingsudo
won't help.What you can do:
sudo emacs /etc/profile
C-x C-q
to toggle readonly mode within EmacsC-x C-s
to save itAlternatively you can run
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).