linux系统解决“XXXX不在 sudoers 文件中。此事将被报告。”问题

1.切换至root用户:

[sunweikai@localhost ~]$ su root

2.查看etc/sudoers权限:

[root@localhost sunweikai]# ls -l /etc/sudoers

如果是只读权限:

-r--r-----. 1 root root 4328  1月 19  2023 /etc/sudoers

3.那么接下来要修改权限为可写:

[root@localhost sunweikai]# chmod u+w /etc/sudoers

4.执行vim命令,编辑/etc/sudoers文件

[root@localhost home]# vim /etc/sudoers

5.按e键直接编辑

6.利用 回车键 换行,找到 Allow root to run any commands anywhere ,按i键开始编辑,下面的指令会出现插入的字样

## Allow root to run any commands anywhere 
root    ALL=(ALL)       ALL

7.在root ALL=(ALL) ALL 的下一行添加代码:86god ALL=(ALL) ALL

## Allow root to run any commands anywhere 
root    ALL=(ALL)       ALL
86god   ALL=(ALL)       ALL

8.按 ESC 键退出插入模式,然后 键盘输入 :wq 关闭并保存

:wq

9.恢复 /etc/sudoers的权限为440(440权限即为只读权限)

[root@localhost sunweikai]# chmod 440 /etc/sudoers

10.查看/etc/sudoers的权限是否恢复

[root@localhost sunweikai]# ll /etc/sudoers
-r--r-----. 1 root root 4355 12月 26 19:54 /etc/sudoers

11.权限恢复正常,切换至普通用户(此时已经解决问题,如果还有问题,接着往下看)

[root@localhost sunweikai]# su 86god
su: user 86god does not exist or the user entry does not contain all the required fields

如上图出现了切换用户失败问题(若无问题可跳过)

12.

  • 7
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值