What Is the Default Sudo Timeout in Ubuntu?
This article outlines the standard expiration period for sudo privileges in Ubuntu Linux. It provides the specific default duration, explains the underlying configuration setting, and details the steps required to view or modify this timeout value for system administration purposes.
By default, the sudo credential timeout in Ubuntu is set to 15 minutes. This means that after you enter your password successfully for a sudo command, you do not need to re-enter it for any subsequent sudo commands within that 15-minute window. Once this period expires, the system will prompt you for your password again to verify your identity.
This behavior is controlled by the timestamp_timeout
setting within the sudoers configuration file. The value is measured in
minutes. If you need to verify or change this setting, you must edit the
sudoers file safely using the visudo command, which checks
for syntax errors before saving changes.
To modify the timeout, open the terminal and run the following command:
sudo visudo
Locate the line that begins with Defaults. You can add
or modify the timestamp_timeout value directly. For example, to change
the timeout to 30 minutes, add the following line:
Defaults timestamp_timeout=30
To disable the timeout entirely and require a password for every sudo command, set the value to 0:
Defaults timestamp_timeout=0
After making changes, save and exit the file. The new timeout setting will take effect immediately for subsequent sudo sessions. Always exercise caution when editing the sudoers file, as syntax errors can prevent sudo from functioning correctly.