There is a command I run very often using compile that must be run as sudo. I wanted to achieve something similar to the 5min caching of sudo in a shell: if I keep running the command in intervals shorter than 5min it does not prompts me for the password again.

Is there an easy way to achieve that?


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 the sudo method, called tramp-session-timeout. It defaults to 300 seconds, and shall behave as you like.

  • I was literally runing C-u M-x compile RET sudo myscript.sh. I just took a quick look at tramp (I have never used it). Do you mean doing something like this? (let ((default-directory "/sudo::/path/to/script")) (compile "myscript.sh"))
    – Vitorqb
    Dec 14 '18 at 10:57
  • Yes, something like this. Dec 14 '18 at 11:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.