1.修改文件权限,可读写
chmod u+w /etc/sudoers
2.配置修改账户免密
sudo vi /etc/sudoers
找到:
# root and users in group wheel can run anything on any machine as any user
root ALL = (ALL) ALL
%admin ALL = (ALL) ALL
修改为:
root ALL = (ALL) NOPASSWD: NOPASSWD: ALL
%admin ALL = (ALL) NOPASSWD: NOPASSWD: ALL
3.保存之后 sudo 测试下,不用输密码
离线
如果你不用想用root 用户,可以如下操作
找到这个,不动
root ALL = (ALL) ALL
%admin ALL = (ALL) ALL
在后面加上
%wheel ALL=(ALL) NOPASSWD: ALL
ps: wheel是我所在的组,你把wheel改成你所在的组名就可以
离线