查看/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 # 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: #includedir /etc/sudoers.d
该文件的权限为
-r--r----- 1 root root 745 Feb 11 2014 /etc/sudoers
所以通常不建议直接修改该文件
/etc/sudoers文件最后包含了一个目录/etc/sudoers.d
文件不要以~结尾或包含点.
使用命令sudo visudo -f /etc/sudoers.d/users增加文件
user ALL= NOPASSWD: ALL
原文链接:https://www.f2er.com/ubuntu/355938.html