添加用户权限以执行命令不起作用


1

我想添加一个能够执行的用户 “添加用户” “更改密码” 命令。我在visudo中添加了一些我在Stack Exchange回答中找到的配置,但它不起作用。

这是我的 /etc/sudoers 文件:

# This file MUST be edited with the 'visudo' command as root.
#
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
#
# See the man page for details on how to write a sudoers file.
#
Defaults        env_reset
Defaults        mail_badpass
Defaults        secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

# Host alias specification

# User alias specification

# Cmnd alias specification
Cmnd_Alias USER_COMMANDS = /usr/sbin/adduser, /usr/sbin/chpasswd

# User privilege specification
root    ALL=(ALL:ALL) ALL
sano    ALL=(ALL) NOPASSWD: USER_COMMANDS

# Allow members of group sudo to execute any command
%sudo   ALL=(ALL:ALL) ALL

# See sudoers(5) for more information on "#include" directives:

#includedir /etc/sudoers.d

有人知道为什么吗?无论如何它还是要我输入密码或者我得到了:

adduser:只有root可以将用户或组添加到系统中。

Answers:


1

当没有相关配置发生时 /etc/sudoers.d/*,假设用户是安全的 佐野 也在小组中 须藤 。后面的行将覆盖第一个,因此覆盖NOPASSWD标记。

%sudo   ALL=(ALL:ALL) ALL

因此,用户sano必须输入每个命令的密码。

参看这个提示来自 ArchLinux维基

注意: 最自定义的选项应该放在文件的末尾,   因为后面的行会覆盖以前的行。特别是这样的   一条线应该在之后 %wheel 如果您的用户在此组中,则为line。

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.