username is not in the sudoers file. This incident will be reported.

1.切换到root用户下

2.赋予/etc/sudoers文件写权限

chmod u+w /etc/sudoers

3.编辑sudoers文件

vim /etc/sudoers

找到root  ALL=(ALL)  ALL这一行,添加以下其中一行内容:

username         ALL=(ALL)                ALL
%groupname          ALL=(ALL)                ALL
username           ALL=(ALL)                NOPASSWD: ALL
%groupname             ALL=(ALL)                NOPASSWD: ALL

第一行:允许用username执行sudo命令(需要输入密码).
第二行:允许用户组groupname里面的用户执行sudo命令(需要输入密码).
第三行:允许用户username执行sudo命令,并且在执行的时候不输入密码.
第四行:允许用户组groupname里面的用户执行sudo命令,并且在执行的时候不输入密码.

4.取消sudoers文件写权限

chmod u-w  /etc/sudoers

猜你喜欢

转载自www.cnblogs.com/greyson-ma/p/11280675.html