Change sudo password timeout in Ubuntu

In this article, we would cover how to change sudo password timeout in Ubuntu. With the help of sudo command-line utility, a user can execute a command as superuser.

Sometimes, a user has to have superuser privileges before executing a instruction set. So, instead of opening a superuser shell in entirety the user may opt to work with sudo command-line utility.

If you have earlier worked with sudo command-line utility then, you may have noticed that – after you issue instructions with sudo. Subsequent sudo commands would work for a certain time period without the password. With lapse of time you would have to provide the password again.

This happens because of default timeout settings. The default timeout period is 15 minutes. Once that time has lapsed because of inactivity, the user has to provide the password again for sudo to work. The purpose of this article is help you make changes to the timeout period – which will be discussed in next section.

Note: Following operations would require you to have superuser privileges. In case you don’t have one then, we advise you to contact your System Administrator for assistance.

Change sudo password timeout in Ubuntu

Edit the /etc/sudoers file to make the relevant changes. Use a text editor to edit the file, we have used nano text editor –

sudo nano /etc/sudoers

Locate the below text –

Defaults env_reset

And, make the following changes to it –

Defaults env_reset, timestamp_timeout=x

where,

x would be the timeout period in minutes.

If we use x value as 1 then, we would have to provide the password again after 1 minute. So, opt for a value which you are comfortable with.

In conclusion, we have discussed how to change sudo password timeout in Ubuntu.

Additional Info –

In certain cases, you would want the user to provide the password every time sudo is invoked. In that case, we need to use timestamp_timeout value as zero. So, entries in /etc/sudoers file should now reflect –

Defaults env_reset, timestamp_timeout=0

Similar Posts