ubuntu使用sudo时不用输入密码

前端之家收集整理的这篇文章主要介绍了ubuntu使用sudo时不用输入密码前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

查看/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

猜你在找的Ubuntu相关文章