Many times when working with sudo, we notice that it asks for a user password to execute the commands. However, after a while, if we want to use sudo again, we have to type it again. This is a security measure. Today I will show you how to change the default sudo timeout.
So, sudo program is part of the GNU suite. It is a small application that allows the execution of commands with the security privileges of another user. Normally, this “other” user is root.
Generally, Ubuntu-based distributions have sudo enabled. Although this is a security breach for many, it makes life much easier for newcomers.
On the other hand, the more server-oriented distributions like Debian, CentOS or RHEL do not even have it installed.
How to enable sudo on Debian 10?
However, sudo has a grace period. This is that after entering the password, there is a time when you can execute another command without entering the password again.
The previous situation implies a security breach. This has to be said. That’s why it’s possible to change that time to a shorter or a longer one.
Chaging the default sudo timeout
First, open a terminal session.
All sudo settings are stored in the /etc/sudoers
file and need to be modified.
To do so, run the following command:
:~$ sudo nano /etc/sudoers
In this case I’m using a text editor called nano, but you can also use one with a graphical interface.
Once inside the file, you have to place the next line:
However, in some Linux distributions that line does not exist, so you can add it at the end of the file and with the value in minutes you want. For example 1 for one minute.
In case you don’t want to be asked for the password anymore you can put the value one. Clearly this is not recommended at all.
Defaults env_reset,timestamp_timeout=1
Then save the changes and close the file.
And it’s done. Now after one minute, if you use another command with sudo, you will be asked for the password again.
Conclusion
Sudo is an unloved tool by many syadmin for being unsafe, but it is true that for a normal user of the system, it is a great advantage. Today you have learned how to modify the grace time it gives us without asking for the password.
Please share this post with your friends and join our Telegram channel.