取消sudo的密码
终端输入sudo visudo,显示为以下内容:
我们只要修改其中的一点内容,就可以实现sudo不需要输入密码了
# /etc/sudoers
#
# This file MUST be edited with the 'visudo' command as root.
#
# See the man page for details on how to write a sudoers file.
#
Defaults env_reset
# Host alias specification
# User alias specification
# Cmnd alias specification
# User privilege specification
root ALL=(ALL) ALL
# Uncomment to allow members of group sudo to not need a password
# (Note that later entries override this, so you might need to move
# it further down)
# %sudo ALL=NOPASSWD: ALL
# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL
# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL
找到
%admin ALL=(ALL) ALL
注释之,在下面加上
%admin ALL=(ALL) NOPASSWD: ALL
意思是属于admin组的用户可以不需要输入密码执行sudo
如果是
admin ALL=(ALL) NOPASSWD: ALL
也就是去掉百分号,意思就是admin这个用户可以执行sudo
这样做的好处是避免了输入错误,如果出错,退出之后会提示你出错,按e重新编辑,不会出现进不了sudo的情况,安全了很多 。
http://xsbl.org/post/48/
没有评论:
发表评论