centos is not in the sudoers file问题

centos用户下使用sudo + 命令时,报异常“centos is not in the sudoers file”

注:centos为本机用户名,因人而异!

原因:当前的centos用户名没有在/etc/sudoers文件中注册!

解决办法:

1.配置sudoers文件

1)切换到root用户

su root

2)进入sudoers目录

cd /etc

3)增加sudoers文件的写入权限

chmod u+w sudoers

4)编辑sudoers文件

vim sudoers

在root ALL=(ALL) ALL这一行下面,添加:

centos ALL=(ALL) ALL

注:其中centos为本机的用户名,因人而异!

2.恢复sudoers文件的权限

chmod u-w sudoers

 

猜你喜欢

转载自blog.csdn.net/greatxiaoting/article/details/81542533