来自man sudoers
:
timestamp_timeout
Number of minutes that can elapse before sudo will ask
for a passwd again. The timeout may include a frac‐
tional component if minute granularity is insufficient,
for example 2.5. The default is 15. Set this to 0 to
always prompt for a password. If set to a value less
than 0 the user's time stamp will never expire. This
can be used to allow users to create or delete their
own time stamps via “sudo -v” and “sudo -k” respec‐
tively.
如您所见,默认超时sudo
为15分钟。您可以在中更改此值/etc/sudoers
。
您不直接编辑/etc/sudoers
,而是使用visudo
它来进行编辑。
来自man visudo
:
visudo edits the sudoers file in a safe fashion, analogous to vipw(8).
visudo locks the sudoers file against multiple simultaneous edits, pro‐
vides basic sanity checks, and checks for parse errors. If the sudoers
file is currently being edited you will receive a message to try again
later.
因此,键入sudo visudo
一个终端,它将/etc/sudoers
在nano
文本编辑器中打开文件。
查找以下行:
Defaults env_reset
并加入 其中X是你想在几分钟内设置时间。timestamp_timeout=X
因此,例如:
Defaults env_reset,timestamp_timeout=5
如果指定0,将始终询问您密码。如果您指定一个负值,则超时将永远不会过期。
完成后,保存并退出。
请参阅RootSudoTimeout
su
了?曾经吗