在Ubuntu 12上不能使用没有密码的sudo

也许我的问题是愚蠢的,但我真的被卡住了…

我的操作系统是Ubuntu 12.04
我的sudoers:

 #
 #这个文件必须以root用户的“visudo”命令编辑。
 #
 #请考虑在/etc/sudoers.d/中添加本地内容,而不是
 #直接修改这个文件。
 #
 #请参阅手册页以了解如何编写sudoers文件的详细信息。
 #
默认值env_reset
默认是mail_badpass
默认值secure_path =“/ usr / local / sbin:/ usr / local / bin:/ usr / sbin:/ usr / bin:/ sbin:/ bin”

 #主机别名说明

 #用户别名说明

 #Cmnd别名规范

 #用户权限规范
根ALL =(ALL:ALL)ALL
飞镖ALL =(ALL)NOPASSWD:ALL

 #admin组的成员可能获得root权限
 %admin ALL =(ALL)ALL

 #允许组sudo的成员执行任何命令
 %sudo ALL =(ALL:ALL)ALL

有关“#include”指令的更多信息,请参阅sudoers(5):

 #includedir /etc/sudoers.d

一些控制台命令输出:

 $ id dart
 (dart)= 1000(dart),24(cdrom),30(dip),46(plugdev),107(lpadmin),124(sambashare)
 $ sudo ls / root /
飞镖的[sudo]密码

为什么系统要求sudo密码? 我怎样才能避免它?

您可能在sudo或admin群组中,尝试在sudoers文件末尾放置dart NOPASSWD:条目。 Sudoers将匹配文件中的最后一个条目,该条目对应于用户或组,并且作为sudoers和admin之后,他们要求input密码,因此系统会提示您input密码。

这很简单

omid ALL=(ALL) NOPASSWD: ALL 

把这个命令放在文件末尾(重要的)

这是我的,它的工作原理(不要问我关于细节,虽然…我已经在不同的机器上多年,我只是复制和粘贴)。 用户需要在“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 # See sudoers(5) for more information on "#include" directives: # members of the sudo group don't have to enter the pass %sudo ALL=NOPASSWD: ALL #includedir /etc/sudoers.d