Get the App
SLTechnology News&Howtos  ›  Development  › 

How to adjust the session time of sudo commands under Linux

Shulou Source: shulou.com Published: 2022-06-01 15:29:55 09月22日 Update

This article will explain in detail how to adjust the sudo command session time under Linux. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.

When using the sudo command to perform administrative tasks in Linux, you may have noticed that even if you just provided the sudo password, you will be asked to provide it again after a period of time. This occurs because of the time limit for your sudo session (the default setting is 15 minutes). If you still enter the sudo command in the same terminal session after 15 minutes, you will be asked to enter your password again.

Edit / etc/sudoers

First open the / etc/sudoers file with root privileges using the sudo and visudo commands, as follows:

$sudo visudo sets timeout time

Then add the following default value, which means that the sudo password prompt will expire 20 minutes after the user uses sudo.

Defaults env_reset,timestamp_timeout=20

Note: you can set the minutes to any time you need, and it will wait until it times out. If you want to pop up the password prompt for each sudo command executed, you can also set the time to 0 or permanently disable the password prompt by setting the value-1.

The screenshot below shows the default parameters I set in the / etc/sudoers file.

Test timeout

Press Ctrl + O to save the file, and then use Ctrl + X to exit. Then, use sudo to run the command and wait 2 minutes to check if the password prompt timed out to test that the settings are normal.

This is the end of this article on "how to adjust the conversation time of sudo commands under Linux". I hope the above content can be helpful to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

Tags: Time command password prompt file article adjustment again more user face-to-face test input good practical task content reason parameter situation Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker Microsoft Huawei Shulou Technology Redmi