Ubuntu sudo nopasswd方法

来源:互联网 发布:win7回收站恢复数据 编辑:程序博客网 时间:2024/06/01 07:48

1 运行 visudo

2 假设用户名为yourname, 则在最后一行添加:


# User privilege specificationrootALL=(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%sudoALL=(ALL:ALL) ALLyourname ALL=(ALL) NOPASSWD: ALL# See sudoers(5) for more information on "#include" directives:#includedir /etc/sudoers.d


注意两点:

NOPASSWD:ALL 之间(红色部分)是有一个空格的。

2 一定要在最后一行添加,否则会被前面的(包括以%开始的那几句)覆盖。