xxx is not in the sudoers file.This incident will be reported.的解决方法

12 篇文章 0 订阅

新装的虚拟机用户没有sudo权限会弹出以下警告,无法用root权限去更新yum

执行sudo yum -y update的时候

[sandwich@192 ~]$ sudo yum -y update

We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:

    #1) Respect the privacy of others.
    #2) Think before you type.
    #3) With great power comes great responsibility.

[sudo] password for sandwich: 
sandwich is not in the sudoers file.  This incident will be reported.

这时候需要给sandwich这个用户分配sudo权限,请follow以下步骤吧

1.切换回root用户

[sandwich@192 ~]$ su root
Password: 

2.添加sudo文件的写权限

[root@192 sandwich]# chmod u+w /etc/sudoers

3.给sudoers文件添加新用户

vi /etc/sudoers

找到这行 root ALL=(ALL) ALL,在他下面添加xxx ALL=(ALL) ALL (这里的xxx是你的用户名)
ps:这里说下你可以sudoers添加下面四行中任意一条

#允许用户yuser执行sudo命令(需要输入密码).
user            ALL=(ALL)                ALL
#允许用户组user里面的用户执行sudo命令(需要输入密码).
%user           ALL=(ALL)                ALL
#允许用户user执行sudo命令,并且在执行的时候不输入密码.
user            ALL=(ALL)                NOPASSWD: ALL
#允许用户组youuser里面的用户执行sudo命令,并且在执行的时候不输入密码.
%user           ALL=(ALL)                NOPASSWD: ALL

4.取消sudoers文件的写权限

[root@192 sandwich]# chmod u-w /etc/sudoers

这样新用户就可以使用sudo了。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

IT三明治

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值