场景:
在CentOS中建立了一个新用户user,在调用sudo命令时,报:“user is not in the sudoers file. This incident will be reported” 错误,没法执行sudo命令。 shell
分析:
在ubuntu中因为禁用了root用户,默认状况下会把安装系统时创建的用户添加到sudoers中。但在redhat和centos中并无把任何root用户以外的用户默认的添加到sudoers之中。这样咱们在执行sudo 命令时就会出现xxx is not in the sudoers file. This incident will be reported.这样的错误输出。如今为了安全起见比较提倡使用普通用户作平常操做,而在须要超级用户的时候使用sudo 来作,这样,咱们就有必要把一些用户添加到sudoers之中。 ubuntu
解决:
centos
#chmod u+w /etc/sudoers #vi /etc/sudoers 在root ALL=(ALL)ALL行下添加XXX ALL=(ALL)ALL,XXX为你的用户名 #chmod u-w /etc/sudoers