Open a file with su/sudo inside Emacs

Posted by Chris Conway on Stack Overflow See other posts from Stack Overflow or by Chris Conway
Published on 2008-09-18T18:51:47Z Indexed on 2010/06/17 12:23 UTC
Read the original article Hit count: 236

Filed under:
|
|

Suppose I want to open a file in an existing Emacs session using su or sudo, without dropping down to a shell and doing sudoedit or sudo emacs. One way to do this is

(require 'tramp)
C-c C-f /sudo::/path/to/file

but this requires an expensive round-trip through SSH. Is there a more direct way?

[EDIT] @JBB is right. I want to be able to invoke su/sudo to save as well as open. It would be OK (but not ideal) to re-authorize when saving. What I'm looking for is variations of find-file and save-buffer that can be "piped" through su/sudo.

© Stack Overflow or respective owner

Related posts about emacs

Related posts about file-permissions