[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to change and save a read-only file?
From: |
Jude DaShiell |
Subject: |
Re: How to change and save a read-only file? |
Date: |
Sat, 29 Jun 2013 07:16:06 -0400 (EDT) |
On Sat, 29 Jun 2013, Thorsten Jolitz wrote:
> Marius Hofert <marius.hofert@math.ethz.ch> writes:
>
> Hi,
>
> > What's the 'correct' approach to easily edit (change + save) such files?
>
> not sure whats the 'correct' approach, but there is tramp which allows
> you to do something like:
>
> 1. find-file as root
>
> ,---------------
> | C-x C-f /sudo:
> `---------------
>
> and then asks for a password
>
> ,-----------------------------------
> | Password for /sudo:root@localhost:
> `-----------------------------------
>
> to let you subsequently edit the file as root
>
> 2. or reopen dired buffer with sudo and thus open end edit files from
> that buffer as root
>
> ,-------------------------------------------------------------------------------
> | C-c C-s runs the command dired-toggle-sudo, which is an interactive
> autoloaded
> | compiled Lisp function in `dired-toggle-sudo.el'.
> |
> | It is bound to C-c C-s.
> |
> | (dired-toggle-sudo &optional SUDO-USER)
> |
> | Reopen current file or dired buffer with sudo.
> |
> | If SUDO-USER is nil assume root.
> |
> | If called with `universal-argument' (C-u), ask for username.
> `-------------------------------------------------------------------------------
>
> But I finally ended up to write a separate minimal init.el file and a
> small batch script that allow me to quickly open a root instance of
> emacs when I need it that warns me about being root while editing that I
> exit when I'm done with editing:
>
> ,---------------------------------------------
> | -rwxr-xr-x 1 me users 125 26. Apr 09:44 esu
> `---------------------------------------------
>
> with content:
>
> ,------------------------------------------------------
> | #!/bin/sh
> | # start emacs as root
> |
> | exec sudo emacs -Q -bg black -fg wheat --no-splash -l
> | /home/me/.emacs.d/emacs-ESU-script.el
> `------------------------------------------------------
>
> emacs-ESU-script.el:
>
> (it starts up pretty fast, but makes editing convenient, and has a nice
> red warning at the top of the buffer about editing as root)
>
With sudo, you enter your login password. You have to be mentioned in
/etc/sudoers though to do this and have it work. Of course if you have
root privileges, other things are possible.
>
---------------------------------------------------------------------------
jude <jdashiel@shellworld.net> About to block another web browser version?
Ask yourself what Tim Berners-lee would do.