一、linux下sudo权限问题 等报错
liunx新建了一个用户 使用sudo命令 出现了这样的问题
user is not in the sudoers file. This incident will be reported
(用户名) not in the sudoers file. This incident will be reported.
当我们遇到这样的问题时:
①:切换到root用户下
su root
然后输入密码:
密码为你创建用户的密码
②:更改sudoers文件权限
etc/sudoers文件默认是只读的,对root来说也是,因此需先添加sudoers文件的写权限
chmod u+w /etc/sudoers
③:编辑sudoers文件
vi /etc/sudoers
vim /etc/sudoers
找到这行 root ALL=(ALL) ALL,在他下面添加xxx ALL=(ALL) ALL (这里的xxx是你的用户名)
可以sudoers添加下面四行中任意一条 根据自己需要的情况
youuser ALL=(ALL) ALL
%youuser ALL=(ALL) ALL
youuser ALL=(ALL) NOPASSWD: ALL
%youuser ALL=(ALL) NOPASSWD: ALL
第一行:允许用户youuser执行sudo命令(需要输入密码).
第二行:允许用户组youuser里面的用户执行sudo命令(需要输入密码).
第三行:允许用户youuser执行sudo命令,并且在执行的时候不输入密码.
第四行:允许用户组youuser里面的用户执行sudo命令,并且在执行的时候不输入密码.
④:撤销sudoers文件写权限
chmod u-w /etc/sudoers