我在使用个人用户(非root用户)时,在执行其他命令时,使用sudo命令来执行的时候,需要验证当前用户的密码,输入了之后,提示“admin 不在sudoers文件中,此事将被报告”

分析原因,主要是权限不够,需要提升权限。

解决方法:

步骤:

1、先切换至root用户,输入命令:su root,然后输入密码

[admin@localhost ~]$ su root
密码:

2、查看 /etc/sudoers 文件权限,如果只读权限,修改为可写权限

输入查看文件命令:ls –l /etc/sudoers

[root@localhost admin]# ll /etc/sudoers
-r--r-----. 1 root root 4355 11月 24 11:13 /etc/sudoers

由此可看,该文件为只读权限

3、设置 /etc/sudoers 文件权限,添加 可写权限

输入修改权限命令:chmod u+w /etc/sudoers

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

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

输入编辑文件命令:"vim /etc/sudoers"

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

5、查看打印内容

E325: 注意
发现交换文件 "/etc/.sudoers.swp"
            所有者: root    日期: Wed Nov 24 11:10:17 2021
            文件名: /etc/sudoers
            修改过: 是
            用户名: root      主机名: localhost
           进程 ID: 4637 (仍在运行)
正在打开文件 "/etc/sudoers"
              日期: Wed Nov 24 11:39:36 2021
      比交换文件新!

(1) Another program may be editing the same file.  If this is the case,
    be careful not to end up with two different instances of the same
    file when making changes.  Quit, or continue with caution.
(2) An edit session for this file crashed.
    如果是这样,请用 ":recover" 或 "vim -r /etc/sudoers"
    恢复修改的内容 (请见 ":help recovery")。
    如果你已经进行了恢复,请删除交换文件 "/etc/.sudoers.swp"
    以避免再看到此消息。

交换文件 "/etc/.sudoers.swp" 已存在!
以只读方式打开([O]), 直接编辑((E)), 恢复((R)), 退出((Q)), 中止((A)):

6、按e键,直接编辑

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

8、在root ALL=(ALL) ALL 的下一行添加代码:admin ALL=(ALL) ALL

## Next comes the main part: which users can run what software on 
## which machines (the sudoers file can be shared between multiple
## systems).
## Syntax:
##
##      user    MACHINE=COMMANDS
##
## The COMMANDS section may have other options added to it.
##
## Allow root to run any commands anywhere 
root    ALL=(ALL)       ALL
admin   ALL=(ALL)       ALL
## Allows members of the 'sys' group to run networking, software, 
## service management apps and more.
# %sys ALL = NETWORKING, SOFTWARE, SERVICES, STORAGE, DELEGATING, PROCESSES, LOCATE, DRIVERS

## Allows people in group wheel to run all commands
%wheel  ALL=(ALL)       ALL

## Same thing without a password
# %wheel        ALL=(ALL)       NOPASSWD: ALL

## Allows members of the users group to mount and unmount the 
## cdrom as root
# %users  ALL=/sbin/mount /mnt/cdrom, /sbin/umount /mnt/cdrom

## Allows members of the users group to shutdown this system
# %users  localhost=/sbin/shutdown -h now

## Read drop-in files from /etc/sudoers.d (the # here does not mean a comment)
#includedir /etc/sudoers.d

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

## Next comes the main part: which users can run what software on 
## which machines (the sudoers file can be shared between multiple
## systems).
## Syntax:
##
##      user    MACHINE=COMMANDS
##
## The COMMANDS section may have other options added to it.
##
## Allow root to run any commands anywhere 
root    ALL=(ALL)       ALL
admin   ALL=(ALL)       ALL
## Allows members of the 'sys' group to run networking, software, 
## service management apps and more.
# %sys ALL = NETWORKING, SOFTWARE, SERVICES, STORAGE, DELEGATING, PROCESSES, LOCATE, DRIVERS

## Allows people in group wheel to run all commands
%wheel  ALL=(ALL)       ALL

## Same thing without a password
# %wheel        ALL=(ALL)       NOPASSWD: ALL

## Allows members of the users group to mount and unmount the 
## cdrom as root
# %users  ALL=/sbin/mount /mnt/cdrom, /sbin/umount /mnt/cdrom

## Allows members of the users group to shutdown this system
# %users  localhost=/sbin/shutdown -h now

## Read drop-in files from /etc/sudoers.d (the # here does not mean a comment)
#includedir /etc/sudoers.d

:wq

10、恢复 /etc/sudoers的权限为440

输入回复权限的命令:chmod 440 /etc/sudoers

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

11、查看/etc/sudoers的权限是否恢复

输入查看权限命名:ll /etc/sudoers

[root@localhost admin]# ll /etc/sudoers
-r--r-----. 1 root root 4355 11月 24 11:41 /etc/sudoers

12、权限恢复正常,切换至普通用户

输入切换用户命令:su admin

[root@localhost admin]# su admin
[admin@localhost ~]$

13、测试该用户的权限,我们可以使用命令 sudo useradd user1 来创建新用户

[admin@localhost  ~]$ sudo useradd user1

14、此时已经没有了先去的报错,用户也已经创建成功,大功告成!!!

解决 Linux 系统,出现“不在sudoers文件中,此事将被报告”的问题相关推荐

  1. Debian11镜像更新为阿里巴巴开源镜像站镜像,切换root用户,解决用户名不在sudoers文件中此事将被报告,Debian11 文件夹对话框、火狐浏览器、命令终端等没有最大化和最小化

    选择Debian作为编程开发最佳Linux的理由: Debian是面向程序员的最古老,最出色的Linux发行版之一.Debian提供了具有.deb软件包管理兼容性的超稳定发行版.Debian为程序员提 ...

  2. 用户名不在sudoers文件中此事将被报告的解决方法

    用户名不在sudoers文件中此事将被报告的解决方法 参考文章: (1)用户名不在sudoers文件中此事将被报告的解决方法 (2)https://www.cnblogs.com/yongfengni ...

  3. 用户不在 sudoers 文件中此事将被报告

    "用户不在 sudoers 文件中此事将被报告". 出现这个提示,就是这个用户没法得到超级用户权限 sudo的具体执行流程如下: 当用户执行sudo时,系统会自动寻找/etc/su ...

  4. xxx不在 sudoers 文件中,此事将被报告

    执行sudo apt install ***, 输入密码后提示: xxx不在不在 sudoers 文件中,此事将被报告. 问题的原因是我们在安装时没有将用户添加为管理员. 切换超级用户 su # 切换 ...

  5. linux中 不在sudoers文件中此事将被报告

    1.切换到root用户下 2. 打开/etc/sudoers文件,注意此文件的权限!!! 3. 更改文件内容: root ALL=(ALL) ALL 用户名 ALL=(ALL) ALL

  6. 解决“不在sudoers文件中此事将被报告 不能切换root权限“

    参考1: https://blog.csdn.net/m0_59133441/article/details/121511380 我是通过上面这个解决的.说一下我的过程. 开始我使用usermod把我 ...

  7. Linux之用户不在 sudoers 文件中。此事将被报告。

    这个问题是我在用普通用户安装软件包时遇到的.这里分享一下. 问题场景 [fenghx@localhost ~]$ sudo yum install freetds我们信任您已经从系统管理员那里了解了日 ...

  8. 问题以及解决办法:hadoop 不在 sudoers 文件中。此事将被报告

    http://blog.csdn.net/jiangshouzhuang/article/details/52517734 问题来源: 我们使用sudo命令,让Hadoop用户使用root身份执行命令 ...

  9. Linux:XXX 不在 sudoers 文件中。此事将被报告。

    用户XXX不在 sudoers 文件中.此事将被报告. 这种报错直接切换root用户把当前用户添加到sudoers文件中即可. 1.切换root用户,编辑sudoers文件 su root vi /e ...

  10. 【Linux】用户不在sudoers文件中

    *** is not in the sudoers file.  This incident will be reported."  (用户不在sudoers文件中--) 处理这个问题很简单 ...

最新文章

  1. linux 守护进程_Linux 守护进程
  2. android开发标签栏应该设置多少钱,android – Flutter:刷卡后默认标签栏控制器......
  3. C++MFC编程笔记day01 MFC介绍、创建MFC程序和重写消息处理
  4. php 64位编码解码,php base64 编码和解码
  5. JAVA入门级教学之(Object类中的equals方法)
  6. Magento重建所有索引方法
  7. vmware开机自动进入BIOS vmware 进入BIOS方法
  8. w8fuckcdn 通过扫描全网绕过CDN获取网站IP地址
  9. 设计最简单的c语言程序,最简单的C语言程序
  10. 小试牛刀1:制作一个简单的导航栏页面
  11. 关于魔兽守卫军的改进建议
  12. [ 后缀数组 ] [ SDOI2008 ] BZOJ4698 Sandy的卡片
  13. 论文会议推荐到计算机研究与发展,计算机研究与发展类论文参考文献 计算机研究与发展核心期刊参考文献有哪些...
  14. 美团2021-10-4最优二叉树Ⅱ
  15. MongoDB学习笔记(三)
  16. Android gradle统一依赖版本:Composing builds
  17. 序列的自相关和互相关计算
  18. 奇迹按键精灵挂机脚本_奇迹脚本代码导入按键精灵后怎么使用?
  19. oracle创建表空间、临时表空间
  20. OS第二章五大经典PV

热门文章

  1. Ubuntu格式化U盘以及分区
  2. 全平台福利集合大放送!24h后立刻删!冲!
  3. LWN:5.18 合并窗口,第二部分!
  4. Oracle的基本练习:登陆、查看连接、管理登陆用户、修改进程数
  5. 【配置】利润中心会计启用
  6. itext7学习笔记——第2章实践example
  7. 随手记_英语_学术写作_英文科技论文
  8. BUUCTF | [INSHack2017]sanity | [INSHack2019]INSAnity | [INSHack2019]Sanity | [INSHack2017]insanity-
  9. 移动端开发,苹果手机样式乱,iphon7不支持white-space属性,控制显示几行
  10. @Value读取配置文件报Could not resolve placeholder 'rabbitmq.host' in value'${rabbitmq.host}'或null的问题