[OS X Emacs] Opening and saving files as root

Roland Whitehead rolandw at mac.com
Mon Nov 19 16:49:58 EST 2007


> Using the built in emacs from terminal, it is easy to open a file as
> root
>
> 	sudo emacs path/to/myfile.txt
>
> and from then on that instance of emacs runs as root. I can do
> similar with a remote volume using tramp from Aquamacs
>
> 	/ssh:root at mymachine.mydomain.com:/path/to/myfile.txt
>
> but what I can't work out how to do is do the same using Aquamacs and
> my local machine save using the shell to open Aquamacs as root in the
> first place. I've found sudo.el but that just seems to cope with
> saving rather than opening.

Peter Dyballa pointed the way. TRAMP is, of course, the solution and  
you just use the inline connection "sudo" hence

	C-x C-f /sudo::/path/to/myfile.txt

will prompt for the sudo password (or not, if you have set up sudo  
with visudo correctly) and you are in. You could also use /su::  
assuming that you want to use the root password (not usually  
recommended).

Thanks for the suggestions.


Roland



More information about the MacOSX-Emacs mailing list