栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

Linux系统 sudo su命令报 ...is not in the sudoers file. This incident will be reported.

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Linux系统 sudo su命令报 ...is not in the sudoers file. This incident will be reported.

sudo 命令不再解释,普通用户登录使用sudo su 命令执行不成功,提示...is not in the sudoers file. This incident will be reported.

这是因为当前用户不具有sudo特权,其由sudoers配置文件来指定, 配置文件位于"/etc/sudoers". 先用su命令切换到root用户, 输入root密码

[zpp@192 ~]$ su -
Password: 
[root@192 ~]# 
 

这里还需要给sudoers文件添加写权限

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


然后编辑sudoers文件

[root@192 ~]# vi ../etc/sudoers
找到如图所示

在 root ALL=(ALL) ALL 这一行下加一句

*** ALL=(ALL) ALL (***为你需要添加权限的用户名)

最后 wq!并且撤销sudoers的写权限

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

Ctrl +d 退出当前用户 使用sudo su 输入当前用户密码 发现欧克了。

*****************************************************************************************************

另外还再网上找到其他几种解决办法可供参考

1,根据用户组及无密码的配置:

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

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

跟第一种配置方式相比,也就在前面多了一个“%”,用来表示用户组。最前面的“#”表示注释, 把"#"去掉即可生效; 而后面的"NOPASSWD:"即表示不需要输入密码就可以执行命令

设置了某个用户组具有sudo权限之后,使用usermod命令把相应的用户添加到该用户组就可以了:

usermod -a -G wheel linuxidcuser

2,通过别名问题来设置,有命令别名,账户别名,主机别名等,具体参考sudoers文件提供的例子:

## Host Aliases ## Groups of machines. You may prefer to use hostnames (perhaps using ## wildcards for entire domains) or IP addresses instead. # Host_Alias FILESERVERS = fs1, fs2 # Host_Alias MAILSERVERS = smtp, smtp2 ## User Aliases ## These aren't often necessary, as you can use regular groups ## (ie, from files, LDAP, NIS, etc) in this file - just use %groupname ## rather than USERALIAS # User_Alias ADMINS = jsmith, mikem ## Command Aliases ## These are groups of related commands... ## Networking # Cmnd_Alias NETWORKING = /sbin/route, /sbin/ifconfig, /bin/ping, /sbin/dhclient, /usr/bin/net, /sbin/iptables, /usr/bin/rfcomm, /usr/bin/wvdial, /sbin/iwconfig, /sbin/mii-tool 

3,在sudoers文件的最后面有如下几行,利用include引入/etc/sudoers.d目录下的配置文件,

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

sudo与su的联合使用

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/889937.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号