解决linux下sudo更改文件权限报错xxxis not in the sudoers file. This incident will be reported.
Linux中普通用户用sudo执行命令时报 xxx is not in the sudoers file.This incident will be reported 错误,解决方法就是在 /etc/sudoers 文件里给该用户添加权限…
1、切换到root用户:su
2、修改sudoers文件写权限:
/etc/sudoers
文件默认是只读的,对root来说也是,因此需先添加 sudoers
文件的写权限: chmod u+w /etc/sudoers
;
3、编辑sudoers文件:vim /etc/sudoers
找到这行 root ALL=(ALL) ALL
,在他下面添加 xxx ALL=(ALL) ALL
(这里的xxx是你的用户名)
注:sudoers格式示例如下:
youuser ALL=(ALL) ALL |
说明:
• 第一行:允许用户youuser执行sudo命令(需要输入密码).
• 第二行:允许用户组youuser里面的用户执行sudo命令(需要输入密码).
• 第三行:允许用户youuser执行sudo命令,并且在执行的时候不输入密码.
• 第四行:允许用户组youuser里面的用户执行sudo命令,并且在执行的时候不输入密码.
4、撤销sudoers文件写权限
命令: chmod u-w /etc/sudoers