how to edit a file as admin
- From: Xah Lee <xahlee@xxxxxxxxx>
- Date: Fri, 23 Apr 2010 08:15:46 -0700 (PDT)
Another little emacs tip. The tip is about how to edit files that
requires admin privilege.
Often, you want to edit a file that requires admin privilege. So,
either you start another emacs instance as root, or, modify the file's
permission first with sudo then edit then modify it back. Both
solutions are painful.
Starting another emacs instance is slower, and you also need to
navigate to the dir path. Edit permission bits is error pron and
dangerous.
When i was a full time unix sys admin, i usually always keep a
instance of emacs as root, with different colored background. But this
is also not a optimal solution.
Here's one short tip from the web:
; from newsgroup gnu.emacs.help, by Richard Riley, 2009-08-02
(defun open-current-file-as-admin ()
"Open the current buffer as unix root.
This command works on unixes only."
(interactive)
(when buffer-file-name
(find-alternate-file
(concat "/sudo:root@localhost:"
buffer-file-name))))
PS the above works in unixes only (including linuxes and Mac OS X).
How does one do on Windows? If you know, please post! Concrete
solution that you actually use is prefered. No general reference
please.
Xah
∑ http://xahlee.org/
☄
.
- Follow-Ups:
- Re: how to edit a file as admin
- From: Tassilo Horn
- Re: how to edit a file as admin
- Prev by Date: Re: emacs lisp tutorial: Count Words and Chars
- Next by Date: Einstein's cosmolological constant repulsive force
- Previous by thread: linux init file problem
- Next by thread: Re: how to edit a file as admin
- Index(es):
Relevant Pages
|