CentOS 之 XXX is not in the sudoers file解决方法

背景:安装好CentOS后,安装PHP

输入命令 sudo yum install httpd

系统报错 'XXX is not in the sudoers file. This incident will be reported.'

原因 我的账号 XXX 没有使用sudo的权限

解决方法:修改/etc/sudoers

步骤:

1、进入超级用户模式。即输入"su -"

  (注意有- ,这和su是不同的,在用命令”su”的时候只是切换到root,但没有把root的环境变量传过去,还是当前用户的环境变量,

  用”su -”命令将环境变量也一起带过去,就象和root登录一样

  ——这个是引用自http://blog.csdn.net/leroy008/article/details/18046645   不太理解@_@)

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

3、编辑/etc/sudoers文件。即输入命令"gedit /etc/sudoers",进入编辑模式,

  找到:"root ALL=(ALL) ALL"在起下面添加XXX ALL=(ALL) ALL"

  (这里的XXX是我的用户名),然后保存退出。

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

慢慢学些吧~

原文地址:https://www.cnblogs.com/la-isla-bonita/p/3572738.html