码迷,mamicode.com
首页 > 系统相关 > 详细

Linux中新建用户用不了sudo命令问题:rootr is not in the sudoers file.This incident will be reported解决

时间:2018-07-27 14:36:29      阅读:184      评论:0      收藏:0      [点我收藏+]

标签:passwd   输入   csdn   保存   host   ora   出现   sudo命令   alt   

参考:https://blog.csdn.net/lichangzai/article/details/39501025

 

如果执行sudo命令的用户没有执行sudo的权限,执行sudo命令时会报下面的错

[rootr@localhost ]# sudo yum install gcc-c++ 
rootr is not in the sudoers file.This incident will be reported

设置用户执行sudo命令权限,建议这些操作都在secureCRT内进行要不然当走到进入sudoers那一步时,会出现问题
方法如下:    
1、进入超级用户模式。也就是输入"su -",系统会让你输入超级用户密码,输入密码后就进入了超级用户模式。

2、添加文件的写权限。也就是输入命令"chmod u+w /etc/sudoers"。

技术分享图片

 
3、编辑/etc/sudoers文件。也就是输入命令"vim /etc/sudoers",输入"i"进入编辑模式,
找到这一行:"root ALL=(ALL) ALL"在起下面添加"xxx ALL=(ALL) ALL"(这里的xxx是你的用户名),比如我这里是rootr所以我的语句是:rootr ALL=(ALL) ALL

技术分享图片

如果要让执行时不需要输入密码,再找到下面这一句
# %wheel  ALL=(ALL)       NOPASSWD: ALL

并去掉注释#:
%wheel  ALL=(ALL)       NOPASSWD: ALL

然后保存(就是先摁一下Esc键,然后输入":wq")退出。

4、将你的用户(普通用户)调整至“ wheel ”用户组里面。
gpasswd -a YourUserName wheel

这样,就可以每次执行 sudo 命令时不再输入密码了

5、撤销文件的写权限。也就是输入命令"chmod u-w /etc/sudoers"。

[oracle@dev ]$ su root
[root@dev ]# chmod u+w /etc/sudoers
[root@dev ]# vim /etc/sudoers
[root@dev ]# chmod u-w /etc/sudoers
[root@dev ]# gpasswd -a rootr wheel

[root@dev ]# su rootr

 

截图:

技术分享图片

 之后就可以执行sudo啦,截图留念:

技术分享图片

 

Linux中新建用户用不了sudo命令问题:rootr is not in the sudoers file.This incident will be reported解决

标签:passwd   输入   csdn   保存   host   ora   出现   sudo命令   alt   

原文地址:https://www.cnblogs.com/rgever/p/9377046.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!