user is not in the sudoers file

使用用户账户使用sudo来运行一些特权命令时出现了如下错误
(sudo是一个允许特定的用户组用另一个用户(典型的是root)的特权来运行一个命令):
user is not in the sudoers file.  This incident will be reported.

意思是你不在这个包含经过认证就可以使用sudo特权的这么一个用户组的sudoers列表里。

在Sudoers列表里添加用户

第一步:在root用户下编辑sudoers配置文件。将与wheel组相关的配置信息前的注释符号“#”去掉。使所有属于wheel组的用户具有root用户的所有命令执行的权限。

[root@localhost ~]# visudo
-------------修改前---------------
#%wheel ALL=(ALL)       ALL
# Same thing without a password
#%wheel ALL=(ALL)       NOPASSWD: ALL
-----------修改后-----------------
%wheel ALL=(ALL)       ALL
# Same thing without a password
%wheel ALL=(ALL)       NOPASSWD: ALL

第二步:将oracle用户添加到wheel组中,在group文件中找到“wheel”关键字所在行记录。 在wheel记录后面添加“,oracle”,实现将oracle用户加入到wheel组中

[root@localhost ~]# vi /etc/group
wheel:x:10:root,oracle

第三步:测试 我们可以使用“id”命令简单测试一下sudo命令的可用性。在需要测试用户下使用id命令获得当前用户的信息

[oracle@secdb1 ~]$ id
uid=500(oracle) gid=501(oinstall) groups=10(wheel),500(dba),501(oinstall)

注释:关于sudo的深入配置方法,可以使用 man sudo 自行查询

原文地址:https://www.cnblogs.com/xujint/p/13162929.html