首页 > 其他 > 详细

CentOS - 解决非root账号无法执行带sudo命令!!

时间:2020-09-14 14:52:11      阅读:63      评论:0      收藏:0      [点我收藏+]

CentOS版本:8.2

假设我要用的账号为:test

默认安装完毕后,使用非root账号执行带sudo的命令,想获取管理员权限执行此命令,发现无法执行,提示:

test is not in the sudoers file, This incident will be reported.

解决方法:在sudoers文件中加入要执行此命令的用户

1,切换成root账号

su 

随后输入root账号,切换为root身份!

2,修改sudoers文件

gedit  /etc/sudoers

打开这个文件后,查找:root ALL=(ALL) ALL 这行,随后在这行下面加入:你的用户名 ALL=(ALL) ALL ,随后保存退出就可以了!!

编辑后这个地方应该是:

root ALL=(ALL) ALL

test ALL=(ALL) ALL

在shell里面输入:

su test

随后输入test的密码就可以了,切换为test身份了,随后输入测试命令:

sudo echo hello

这个时候就应该可以了!!

参考:

https://blog.csdn.net/BXD1314/article/details/16102633

 

CentOS - 解决非root账号无法执行带sudo命令!!

原文:https://www.cnblogs.com/sunylat/p/13666249.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!