Want to change the sudo timeout on your Linux distro?
It’s easy to do and the same steps work on all Linux distributions, regardless of release, version, package manager, desktop environment, or anything else.
Sip down to the how-to or read on for a bit of context as to why some people choose to change the sudo timeout period.
sudo timeout
By default, a standard sudo session lasts for 5 minutes (on some distributions, e.g., Ubuntu, it is 15 minutes).
During a ‘sudo session’ you will only need to enter your root password once in whatever terminal tab you’re working from. Any time you run a sudo
command during this time it will run without prompting you to type in your password.
Once 5 minutes has passed any sudo
command you try to run will require you enter your password again.
Now, having to repeatedly re-enter your password to run sudo commands is not a hardship. In most cases you don’t need to change the default value as the timeout period is usually long enough for most standard user tasks,
But when I work from the command line it’s for an extended period, and as I’m the only person using my laptop (I don’t leave it unattended) I’m okay with extending the sudo timeout so I have to re-enter my password less often.
Changing the sudo timeout

To change the sudo timeout on Linux you can use the sudo visudo
command. This will enable you to edit the sudoers
file for your system from the terminal, using your distro’s default command-line text editor.
- Open a new Terminal window
- Run:
sudo visudo
- Find the uncommented line:
Defaults env_reset
- Under this line type:
Defaults timestamp_timeout=<time-in-minutes>
- Save the changes (
ctrl
+o
in Nano) and exit (ctrl
+x
in Nano)
Replace <time-in-minutes>
with a number corresponding to the amount of minutes you want the sudo timeout period to last. For example, if you want the timeout to last 60 minutes, the line should read: Defaults timestamp_timeout=60
.
That’s it! You’ve successfully changed the sudo timeout on Linux. Note that this change will apply to all users with sudo access so be careful when modifying the sudoers
file.