Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Going root when writing to file/saving file?

Is it possible to open a file(in root location) as non-root user in Emacs, edit it and then when its time to save provide the password so the Emacs can get write to the file? Better still provide different buffers with different user privileges?

I know of Tramp but couldn't get my head around it.

like image 679
Bleeding Fingers Avatar asked Feb 16 '23 04:02

Bleeding Fingers


1 Answers

Here's how I do it:

(require 'tramp)
(defun sudired ()
  (interactive)
  (dired "/sudo::/"))

You'll get a dired buffer where you have root privileges. Any subsequent directory or file that you open from here will be with root.

Any other dired buffers will not be affected.

like image 85
abo-abo Avatar answered Feb 23 '23 00:02

abo-abo