By default on Ubuntu, after 15 minutes of sudo sessions, you’ll have to re-enter your password to continue using the sudo command tool. This can be frustrating in some cases, and if you find yourself in similar situations, follow the steps below to change how often sudo sessions terminate. Out of the box, if you enter your password to run a sudo command, you can continue to run subsequent commands using the existing session for 15 minutes. When the 15 minutes are out, you’ll be forced to reenter your password.

How to manually set Sudo Timeout Limits

Without you modifying the Sudoers file, you can manually set when you want a sudo session to last by running a simple command. For example, if you want to use an existing sudo session for forever until you terminate it, simply run the sudo command with an -s or the –shell option. The -s option allows you to run the shell as the target user who is running it. Example: With that you can continue to use an existing sudo session forever until you terminate it with an -k or the –reset-timestamp option: Then -k option invalidates the timestamp file. Example: If you initiated a sudo session with sudo -s option, the -k option will not terminate the sessions. You must exit to end that session.

Set Sudo Timeout Sessions Globally

If you want to extend or reduce this default timeout limit for the sudo session globally or system-wide, simply on the sudoers file and make the changes there. Run the commands below to open the file. Then on the highlighted line, change how long you want sudo sessions to last for everyone. For example, if you want all sudo sessions to last for an hour, add the highlighted line to the file and save. Save the file and exit. That’s it! Conclusion: This post shows you how to quickly and easily adjust sudo session time limits on Ubuntu 18.04 | 16.04 systems. If you find any error above, please use the form below to report it. Thanks, You may also like the post below: