The question pretty much says it all. I opened emacs as a regular user and am trying to edit something in the /etc/ folder (I know this is dangerous etc. etc.)

How can I do this?


You could use https://stackoverflow.com/questions/95631/open-a-file-with-su-sudo-inside-emacs, for example C-x C-f /sudo::/path/to/file

  • True. I guess this question should be closed or linked to that answer directly.
    – Startec
    Jul 12 '16 at 6:07

There is packages that gives some utilities functions for this:

  • sudo-edit for opening buffers as root
  • dired-toggle-sudo for switching from current user to sudo when browsind dired buffers.

Also see the Edit file with super-user rights question.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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