sudo: sudoers NOPASSWD选项不工作?

分享于 

2分钟阅读

ubuntu

  繁體

问题

我在/etc/sudoers有一行NOPASSWD (使用visudo编辑)


gatoatigrado ALL=(ALL) NOPASSWD: /bin/set-slow-cpufreq



但是,输出是,


gatoatigrado@coral:~> sudo -n /bin/set-slow-cpufreq


sudo: sorry, a password is required to run sudo



注:我找不到相关的系统日志消息,例如通过tail -f /var/log/syslog

这里是/etc/sudoers。


Defaults env_reset



# things I've tried copying from an opensuse machine


Defaults always_set_home


Defaults env_keep ="LANG LC_ADDRESS LC_CTYPE LC_COLLATE LC_IDENTIFICATION LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER LC_TELEPHONE LC_TIME LC_ALL LANGUAGE LINGUAS XDG_SESSION_COOKIE"



root ALL=(ALL:ALL) ALL


gatoatigrado ALL=NOPASSWD: /bin/set-slow-cpufreq


%admin ALL=(ALL) ALL


%sudo ALL=(ALL:ALL) ALL




答案1

你应该将该行放在sudo组的规则之后,因为sudoers手册页这么说:


 When multiple entries match for a user, they are applied in order.


 Where there are multiple matches, the last match is used (which is not


 necessarily the most specific match).




答案2

Ubuntu安装程序提示一个非root管理员用户,这个用户被添加到组sudo,然后,我使用sudoers手动将自己添加到sudo visudo文件中:


my_username ALL=(ALL:ALL) NOPASSWD:ALL




SUDO  nop  Sudoers  
相关文章