I find that if I execute something using sudo that then if I execute something else soon after also using sudo, that it does not prompt me for my password, and although this can be inconvenient in some situations, it is a security risk in others, and a hassle to keep on coming back and executing the command to make it prompt your for the password on the next go. So I was wondering if and how I could get it to prompt me every time, or for it to at least only remember my password for a very short amount of time?


Open Terminal and type:

sudo visudo

Then scroll down to the line that reads:

Defaults        env_reset

And change it to:

Defaults        env_reset,timestamp_timeout=0

You can change 0 to any values (time in minutes). Setting it to 0 will ask for your password every time and -1 will make it never ask. The default is 15 according to man sudo 8, but some manuals say the default is 5. Have a look at the RootSudoTimeout wiki for more information.

Press CTRL + X to finish editing, Y to save changes, and ENTER to exit.

  • What's the default timeout period? – LDC3 Jun 13 '15 at 18:08
  • Yes, sorry about that. 15 mins according to man sudo 8, but some manual says 5 – Ron Jun 13 '15 at 18:17
  • Believe the manual you have on your system. Different distributions can chose their own defaults. – terdon Jun 13 '15 at 21:04
  • 1
    Believe the source, rather than the manual. – waltinator Jun 13 '15 at 21:15

From Terminal run:

echo "testuser1  ALL=(ALL)   PASSWD: ALL" >> /etc/sudoers


visudo -f /etc/sudoers

Add the following line at the bottom of the file:

testuser1 ALL=(ALL)   PASSWD: ALL

Your Answer

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