Linux “sudo”命令是如何工作的?
我的理解是sudo是以root权限执行给定的命令,但我体验到,在终端中使用sudo输入命令会缓存授权。它实际上是如何工作的 例如Linux “sudo”命令是如何工作的?,linux,ubuntu,terminal,ubuntu-12.04,sudo,Linux,Ubuntu,Terminal,Ubuntu 12.04,Sudo,我的理解是sudo是以root权限执行给定的命令,但我体验到,在终端中使用sudo输入命令会缓存授权。它实际上是如何工作的 例如 sudo fdisk -l [sudo] password for xxxxx: 通过输入密码进行授权后,后续sudo命令不会提示输入密码 sudo fdisk -l 不提示输入密码 sudo mount -t vfat /dev/sda1 /media/test sudo是否真的是su替换/切换用户的包装器?man sudo会告诉我们: Security
sudo fdisk -l
[sudo] password for xxxxx:
通过输入密码进行授权后,后续sudo命令不会提示输入密码
sudo fdisk -l
不提示输入密码
sudo mount -t vfat /dev/sda1 /media/test
sudo是否真的是su替换/切换用户的包装器?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和su命令有点不同: 1.当我们启动su命令时,它将作为一个纯粹的管理员,我们可以在该会话时间内永久使用它 2.然而,sudo命令充当拥有或分配管理员权限的角色,我们可以说它只是该会话的临时权限 另一个例子: 在windows系统中,希望您已选中右键单击属性,如“以管理员身份运行”,这与sudo相同。 如果我们登录或将用户切换到Admin,它将完全充当所有程序的管理员。
希望您已经理解了我的示例,这是我的最佳选择在您的/etc/sudoers中,您可以编辑sudo配置 有一个默认的授权超时 您甚至可以使用sudo分配一些用户,而无需密码。
或者某些用户一旦获得授权,在您注销系统之前不需要密码。不,sudo和su不一样!它的工作原理是在/var/db/sudo中缓存特定用户在特定时间对特定术语进行身份验证的事实