I execute quite a lot of sudo
commands.
I noticed that if I execute one and then another one within few minutes, the 2nd time I don't get the message:
[sudo] password for my_username:
but I do get it when there is more time between the execution of the two commands.
What's the period of time in which the message is not appearing? How can we check it / update it?
Best Answer
The default timeout of
sudo
is 15 minutes; that is,sudo
will remember your password for 15 minutes by default.You can modify this default timeout by adding a string in the file
/etc/sudoers
. However, you don't modify the file directly, but instead you use the commandsudo visudo
.So, type
sudo visudo
in a terminal. This will open up the (actually, a temporary) file for us to edit, using your preferred editor.Look for this line:
And add
timestamp_timeout=X
(with a comma) at the end of it, where X is the time you want to set in minutes.So your line should look like this, as an example:
If you specify 0, you will always be asked the password. If you specify a negative value, the timeout will never expire.
Once done, save and exit.
Source: RootSudoTimeout