3

I usually use Linux as my standard working system and I learned a lot from actually using it. For this particular question I found no answer yet.

The sudo command usually remembers me typing in my password for a given time (usually 15 minutes I guess). Is it possible to extend this time to an undefined length but instead ask for the password again after locking my screen?

I always lock my screen when I leave my computer alone (even for seconds) and would like to not always retype my password when doing something.

I dont want to disable the password check in general. If I let anyone doing anything on my computer they still shouldnt be able to use the sudo command without me typing it once first.

  • What does your research say? – Ramhound Sep 29 '16 at 13:36
  • An alternative solution would be to keep a su termial open for commands that need sudo-powers and to just make sure that you password lock your screen when leaving. – jadsq Sep 29 '16 at 13:36
  • My research indicates that basically it would involve running a bash script in the background, that keeps sudo active, sort of a hack if you wask me. Although given that it is possible on OS X I can't imagine Ubuntu does not have something similar. So what does your research show is the case? – Ramhound Sep 29 '16 at 13:39
  • I haven't found anything regarding this to be honest. There seems to be no functionality for this but the answer I selected is promising. – Alex Oct 3 '16 at 13:15
  • look into your /etc/pam.d/ files, you should be able to set a more desirable timeout/ memory of sudo there. – linuxdev2013 Oct 4 '16 at 19:26
3

If you can make your screen-lock mechanism run an extra command on locking, then you can edit /etc/sudoers to add a line for your user id, eg myname, which says

Defaults:myname timestamp_timeout=-1

This makes the timeout infinite. To revoke your sudo rights explicitly, run sudo -k from your screen-lock.

As usual when editing this file take precautions, eg use sudo visudo and ensure you have a root shell ready in some other terminal.

|improve this answer|||||
  • This sounds like a wonderful idea. Will try it and check back as soon as I was able to. Sounds like this is the solution. – Alex Oct 3 '16 at 13:16

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.