如何“sudo"命令有效吗? [英] How "sudo" command works?
本文介绍了如何“sudo"命令有效吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的理解是 sudo 以 root 权限执行给定的命令,但我经历过在带有 sudo 缓存的终端中输入命令授权.它实际上是如何工作的?
My understand is that sudo is executes a given command with root privileges, but I experienced that entering a command in Terminal with sudo caches the authorization. How does it actually works?
例如
sudo fdisk -l
[sudo] password for xxxxx:
(一旦我通过输入密码授权,连续的 sudo 命令不会提示输入密码)
(once I authorize by entering a password, successive sudo commands are not prompting for passwords)
sudo fdisk -l
(不提示输入密码)
sudo mount -t vfat /dev/sda1 /media/test
sudo 是否真的是 su(替代/切换用户)的包装器?
Whether sudo is really a wrapper for su (substitute/switch user)?
推荐答案
man sudo
会告诉:
Security policies may support credential caching to allow the user to
run sudo again for a period of time without requiring authentication.
The sudoers policy caches credentials for 15 minutes, unless overridden
in sudoers(5). By running sudo with the -v option, a user can update
the cached credentials without running a command.
它还说:
-k [command]
When used alone, the -k (kill) option to sudo invalidates
the user's cached credentials. The next time sudo is run a
password will be required. This option does not require a
password and was added to allow a user to revoke sudo
permissions from a .logout file. Not all security policies
support credential caching.
When used in conjunction with a command or an option that
may require a password, the -k option will cause sudo to
ignore the user's cached credentials. As a result, sudo
will prompt for a password (if one is required by the
security policy) and will not update the user's cached
credentials.
这篇关于如何“sudo"命令有效吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文