centos XXX is not in the sudoers file. This incident will be reported.
源文:http://www.cnblogs.com/evasnowind/archive/2011/02/04/1949113.html
一、
/etc/sudoers /etc/sudoers.bak /usr/share/man/man5/sudoers.5.gz
然后需要切换到root用户,更改/etc/sudoers的权限
[root@localhost xiaofei]# chmod u+w /etc/sudoers
然后就可以利用vi编辑器来把用户添加到sudoers之中
[root@localhost xiaofei]# vi /etc/sudoers
然后找到root ALL=(ALL) ALL所在的位置,把所要添加的用户添加到文件之中,
顺便提一下vi编辑器的用法。刚进入vi编辑器的时候牌命令行模式,这时可以通过方向键来移动光标,找到要编辑的位置之后按下“i”,然后就进入了插入模 式,这时候你可以输入或删除字符。编辑完成之后按“esc”键退出插入模式,进入命令行模式,这时候按“:”可以进入末行模式,输入“wq”保存并退出。
下面是添加完的结果。
## Allow root to run any commands anywhere
root ALL=(ALL) ALL
xiaofei ALL=(ALL) ALL (这一行是添加的内容,xiaofei是我的用户名)
然后需要把sudoers 的写权限去掉(否则系统不允许执行suoders文件):
[root@localhost xiaofei]# chmod u-w /etc/sudoers
至此,在退出root用户之后就可以利用sudo命令来执行超级用户的权限了。