Wednesday, May 1, 2024
 Popular · Latest · Hot · Upcoming
44
rated 0 times [  44] [ 0]  / answers: 1 / hits: 7760  / 2 Years ago, fri, august 5, 2022, 6:02:32

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?


More From » sudo

 Answers
5

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 command sudo 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.




Note: if you are using visudo for the first time, you should be asked which editor you would like to use, so choose your editor. There's no "better" editor, but I prefer nano. If you've already used visudo and chose an editor before, but you want to use another editor for the time being, you can do sudo EDITOR=vi visudo to use vi, or change it to nano to use nano. If you want to permanently change your preferred editor, do sudo update-alternatives --config editor.




Look for this line:



Defaults    env_reset


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:



Defaults    env_reset,timestamp_timeout=5


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


[#30703] Sunday, August 7, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
adedes

Total Points: 454
Total Questions: 114
Total Answers: 111

Location: Turks and Caicos Islands
Member since Fri, May 8, 2020
4 Years ago
;