Skip to main content
8 votes

How to execute sudo command in org-babel in relative path under current working directory

You must use an absolute local directory path. Like this: #+begin_src shell :dir "/sudo::/data/code/quirc" :cache no make sudo make install #+end_src See the leading slash in /data/code/quirc. Edit:...
Michael Albinus's user avatar
7 votes
Accepted

How to run sudo commands using shell-command?

When default-directory points to a sudo-ized path, shell-command uses this environment. Try (let ((default-directory "/sudo::")) (shell-command "ls")) The password will be asked interactively.
Michael Albinus's user avatar
7 votes

Edit file with super-user rights

If you use Helm. You don't need any external package / additional config. it works out of the box. Inside helm-find-files you can invoke find file as root which bound to C-c r. This works for files ...
azzamsa's user avatar
  • 644
6 votes
Accepted

How to make Org-Babel support tangel to su/sudo file with tramp-sudo?

You can prefix tangle file path with /sudo::. #+NAME: privoxy config for convert socks5 to HTTP proxy #+BEGIN_SRC conf :tangle "/sudo::/etc/privoxy/config" listen-address localhost:8118 forward-...
stardiviner's user avatar
  • 1,958
6 votes

Edit file with super-user rights

If you use the ivy package, and have configured counsel-find-file to replace find-file, then one of the "ivy actions" pre-configured for you already is to edit the file as root. The default hydra ...
user1404316's user avatar
6 votes
Accepted

How to execute sudo command in org-babel in relative path under current working directory

I suddenly come up with string concat idea. Here is the very simple solution. #+begin_src sh :dir (concat "/sudo::" (expand-file-name "data/code")) pwd #+end_src #+RESULTS[(2020-...
stardiviner's user avatar
  • 1,958
4 votes

how to execute sudo su --login username command with TRAMP

The variable tramp-methods keeps the arguments which Tramp uses for different methods. For sudo, there is the entry `("sudo" (tramp-login-program "env") (tramp-login-...
Michael Albinus's user avatar
4 votes

Can I acquire root privilege to edit a system file without restarting emacs with `sudo`?

With a Tramp method: C-x C-f /sudo::/your/system/file/here That is just add the prefix "/sudo::" before your file and Emacs will ask you your sudo password. :-)
Dieter.Wilhelm's user avatar
3 votes
Accepted

Sudo caching on compilation mode

I suppose you are using Tramp's sudo method to run the command with root permissions from Emacs. With a very recent snapshot of Tramp 2.4.1-pre (or 27.0.50), there is a new configuration parameter to ...
Michael Albinus's user avatar
2 votes

Circumvent sudo fingerprint in tramp

Sudo doesn't give the calling user much control over authentication methods. But you can get some control through the PAM stack. One way to solve your problem would be to have sudo detect when it's ...
Gilles 'SO- stop being evil''s user avatar
2 votes
Accepted

How to overwrite protected files in dired

I can reproduce the problem with Emacs 28.3 / Tramp 2.5.4-pre. Running the very same recipe with Emacs 29.0.90 / Tramp 2.6.0.29.1 works as expected. Emacs 29.1 is in pretest. So I recommend for the ...
Michael Albinus's user avatar
2 votes
Accepted

How to avoid using auth-sources when editing with sudo?

This is the same question as discussed in https://debbugs.gnu.org/46674 In short: Use Tramp 2.5 from GNU ELPA, and apply in your .emacs (connection-local-set-profile-variables 'remote-without-auth-...
Michael Albinus's user avatar
2 votes

Can I acquire root privilege to edit a system file without restarting emacs with `sudo`?

You should checkout this page of DOOM. There is a function which does this: (defun doom/sudo-find-file (file) "Open FILE as root." (interactive (list (read-file-name "Open as root: "))) (...
Aquaactress's user avatar
  • 1,473
1 vote

How can I change TRAMP sudo password timeout?

TRAMP only asks for the password when sudo requires it to ask. If you want to configure how sudo works, then read the manual page for sudo.
db48x's user avatar
  • 19.1k
1 vote

Emacs, .historian and root user

This is the solution I use to edit files as root using a single running emacs daemon: export EDITOR="emacsclient --tty --create-frame" alias e="$EDITOR" alias E=sudoedit
Erik Hetzner's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible