Weblog entry #1 for yaarg

sudo from within emacs
Posted by yaarg on Thu 1 Dec 2005 at 20:07
Tags: none.
I've fallen in love with emacs recently, after taking the time to learn how to use properly and now I typically have emacs open for the entire time I'm using my computer. With Ion's app script, I simple need to press the windows key + e to jump to whether it may be.

One thing that I haven't found a solution for yet though, is how I edit a root owned file from an already open emacs? At the moment, I switch to an xterm and open it up with 'sudo vim' but it would be nice if there was a "open this next buffer with sudo" command?

 

Comments on this Entry

Posted by Steve (82.41.xx.xx) on Thu 1 Dec 2005 at 20:25
[ Send Message | View Steve's Scratchpad | View Weblogs ]

One approach (if you allow root to SSH into your localhost) is to install "tramp". If you do that and place the following inside ~/.emacs then you can open files via SSH:

(require 'tramp)
(setq tramp-default-method "ssh")

For example to open /etc/shadow you'd run:

C-x C-f /root@localhost:/etc/shadow

For more details look at the HTML files installed in /usr/share/doc/tramp.

Steve

[ Parent | Reply to this comment ]

Posted by Anonymous (194.150.xx.xx) on Tue 19 Dec 2006 at 10:05
Try: C-c C-f /su::/etc/passwd

This opens a file as root on the local host using 'su'. The alternative is available with /sudo::/etc/passwd, which uses sudo. See the tramp manual for more information

[ Parent | Reply to this comment ]

Posted by Anonymous (74.100.xx.xx) on Wed 14 Feb 2007 at 14:15
just note that this is different from xemacs;
C-x C-f /[su/]/path/to/file
and so forth. see the documentation for tramp.

[ Parent | Reply to this comment ]

User Login

Username:

Password:

[ Advanced Login ]

Register Account

Quick Site Search