CentOS: xxx is not in the sudoers file. This incident will be reported.

问题

在 centos 中使用非 root 用户执行 sudo 命令的时候会提示:xxx is not in the sudoers file. This incident will be reported.

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 权限
解决办法是修改 /etc/sudoers 文件,添加如下配置:

common           ALL=(ALL)             ALL 
%common          ALL=(ALL)             ALL
%common          ALL=(ALL)             NOPASSWD:ALL
common           ALL=(ALL)             NOPASSWD:ALL

解释说明:

第一行:允许用户 common 执行 sudo 命令(需要输入密码)
第二行:允许用户组 common 里面的用户执行 sudo 命令(需要输入密码)
第三行:允许用户 common 执行 sudo 命令(无需输入密码)
第四行:允许用户组 common 里面的用户执行 sudo 命令(无需输入密码)

在这里插入图片描述
Tips: 若无 /etc/sudoers 文件的写权限,则暂时执行如下命令赋予写权限后再复原,避免误操作

# 赋予 root 写权限
chmod u+w /etc/sudoers
# 改回只读权限
chmod 440 /etc/sudoers
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值