This brief tutorial shows students and new users how change | adjust sudo sessions timeout limit on Ubuntu 18.04 | 16.04.
By default on Ubuntu, after 15 minutes of sudo sessions, you’ll have to re-enter your password to continue using 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 is out, you’ll be forced to reenter your password.
Student or new user looking for a Linux system to start learning on, the easiest place to start is Ubuntu Linux OS…. It’s a great Linux operating system for beginners and folks looking for easier Linux distribution to use.
Ubuntu is an open source Linux operating systems that runs on desktops, laptops, server and other devices.
Both Ubuntu and Windows systems allow you to be productive, easy to use, reliable and enable you to install and run thousands of programs from gaming to productivity suite software for individuals and businesses.
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, 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 shell as the target user who is running it.
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 invalidate timestamp file.
If you initiated 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.
# # This file MUST be edited with the 'visudo' command as root. # # Please consider adding local content in /etc/sudoers.d/ instead of # directly modifying this file. # # See the man page for details on how to write a sudoers file. # Defaults env_reset, timestamp_timeout=60 Defaults mail_badpass Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin" # Host alias specification
Save the file and exit.
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.
You may also like the post below: