为什么添加某个用户sudo 不要密码
#
# 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
# User privilege specification
root ALL=(ALL:ALL) ALL
# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL
# Allow members of group sudo to execute any command
%sudo ALL=(ALL:ALL) ALL
#cqe ALL=ALL NOPASSWD:ALL
# See sudoers(5) for more information on "#include" directives
#includedir /etc/sudoers.d
结果这个样子还是报错:
>>> /etc/sudoers: syntax error near line 9 <<<
>>> /etc/sudoers: syntax error near line 9 <<<
>>> /etc/sudoers: syntax error near line 11 <<<
>>> /etc/sudoers: syntax error near line 12 <<<
>>> /etc/sudoers: syntax error near line 13 <<<
>>> /etc/sudoers: syntax error near line 14 <<<
>>> /etc/sudoers: syntax error near line 15 <<<
>>> /etc/sudoers: syntax error near line 16 <<<
>>> /etc/sudoers: syntax error near line 17 <<<
>>> /etc/sudoers: syntax error near line 18 <<<
>>> /etc/sudoers: syntax error near line 19 <<<
>>> /etc/sudoers: syntax error near line 20 <<<
>>> /etc/sudoers: syntax error near line 21 <<<
>>> /etc/sudoers: syntax error near line 22 <<<
>>> /etc/sudoers: syntax error near line 22 <<<
>>> /etc/sudoers.d/README: syntax error near line 22 <<<
>>> /etc/sudoers: syntax error near line 22 <<<
>>> /etc/sudoers: syntax error near line 22 <<<
>>> /etc/sudoers: syntax error near line 22 <<<
这倒底是什么问题呀?
我应该怎么改呀?
你想要的不是允许
sudo组的用户能够sudo任何命令,而是允许user1用户如此。而且根据
/etc/sudoers文件的提示,我们必须执行sudo visudo命令来修改它。在
%admin后增加一行,内容如下:然后执行
sudo usermod -aG admin user1将其加入admin组。其实我们可以通过
echo <password> | sudo -S <command>来让我们的某个命令无需交互密码。