linux遇到xxx is 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./etc/sudoers文件默认是只读的,对root来说也是,因此需先添加sudoers文件的写权限,命令是: 
即执行操作:chmod u+w /etc/sudoers

3.编辑sudoers文件 
即执行:vi /etc/sudoers 
找到这行 root ALL = (ALL)  ALL,在他下面添加xxx ALL=(ALL) ALL (这里的xxx是你的用户名)

4.撤销sudoers文件写权限,命令:
chmod u-w /etc/sudoers

猜你喜欢

转载自www.cnblogs.com/MakeView660/p/12395542.html