Change sudo default password timeout

By | 2012/08/04

sudo’s default password cache time is 5 minutes. To change the default time, it is possible to edit a setting in /etc/sudoers as desired. I’ll show you how!

Edit /etc/sudoers with your desired text editor, or as standard with sudo visudo:

$ sudo visudo

For example, to increase the timeout to 30 minutes for user jsmith, you would put in a line as follows at the bottom of the file:

Defaults:jsmith timestamp_timeout=30


Save that file, and you are all set.

Additional Notes:
A value of 0 makes sudo always ask for a password. In other words, 0 disables the cache.

Defaults:jsmith timestamp_timeout=0

If set to a value below 0 (ex, -1) the cache will never expire. You should of course never do this, but alas, the option is available.

Defaults:jsmith timestamp_timeout=-1

Leave a Reply

Your email address will not be published. Required fields are marked *

Notify me of followup comments via e-mail. You can also subscribe without commenting.