Hello, friends. Although many don’t like sudo, it must be admitted that many users still use it. And many newbies who are still learning to use Linux should use it. One of the most asked questions is how to change the sudo password time. Let’s go for it.
What is sudo?
Sudo is a GNU application that allows us to execute commands as if we were another user. By default, when you do not specify one, then they will be executed as root user.
This tool is not so valued among many sysadmins, but for many novice users yes because it makes it easy to be root user temporarily.
To use sudo the user has to be enabled for it, and you will have to enter your password to use it. If you use it several times, you will notice that it will only ask for the password once because there is a grace period.
Today’s tutorial will show you how to modify the sudo password time. This way you can control this situation as you wish.
Increasing the sudo password timeout
sudo configuration file is
/etc/sudoers/ and although you can edit it with any text editor, it is recommended that you edit it using a
sudo tool such as
This command has to be executed as root user or using
Once you open it, a terminal text editor will be displayed, and you will be able to edit it.
Locate the line
And add a comma and then
timestamp_timeout = x where
x you will have to replace it with a number expressed in minutes.
Defaults env_reset, timestamp_timeout = 1
In this case, I have defined 1 minute. You can choose
0 to always ask for it or
-1 which is an infinite time, although not recommended at all.
Then save the changes and close the editor. About
nano these changes are saved by pressing
CTRL + O and then
CTRL + X to exit.
We are done. It is also good, though, to clear the
sudo password cache to force it to ask for a password even if the time has not elapsed. To do this run.
And this is it.
In this short post, you learned how to change the sudo password time. This way we will be able to control even more the execution of this tool.