Archive for June 9th, 2014

Adjusting the SUDO timeout

While the sudo flags are convenient, there may be times when you might forget to use these flags. Alternatively, you might wish to have the time-out be longer if you are not concerned about security and regularly find yourself needing to supply your password when running sudo commands. Therefore, you can change the default time-out for sudo to be shorter, longer, or even to disable it altogether and always require a password when running sudo.

To do this, you can specify a custom time-out by editing the sudo configuration file by opening the Terminal and then running the following procedure:

  1. Run the command “sudo visudo” to invoke the sudo configuration editor
  2. Press “i” to invoke “insertion mode” so you can make edits
  3. Use arrows to navigate to the section “# Defaults specification” which will have a number of lines that begin with “Defaults” below it.
  4. Change the line that states “Default env_reset” to have “,timestamp_timeout=NUMBER” (with NUMBER being the number of minutes to time-out) appended to it, so it reads like the following (in this example the number is 2 minutes—if you always want sudo to require a password then set this value to 0):Defaults env_reset,timestamp_timeout=2
  5. Press escape to exit insertion mode
  6. Press “:” followed by typing “w” then “q” and then press enter to save and quit

As always, before making any changes to system configuration files be sure to have a backup of your system (even though “visudo” will create an automatic backup of the sudoers file). To undo these changes, simply invoke the visudo editor again and remove these edits.

 

June 9, 2014 | By More