How to change the sudo password time

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

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

The 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 /etc/sudoers/.

visudo

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

Defaults env_reset

And add a comma and then timestamp_timeout = x where x you will have to replace it with a number expressed in minutes.

For example,

Defaults env_reset, timestamp_timeout = 1
1.- Change the sudo password
1.- Change the sudo password

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.

sudo -k

And this is it.

Conclusion

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.

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"
Angelo
Angelo
I am Angelo. A systems engineer passionate about Linux and all open-source software. Although here I'm just another member of the family.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest articles

Join us on Facebook