在命令行下键入:
$su
,切换到root账户命令行键入:
#visudo
,就会打开sudo的配置文件,文件编辑方法同vi在打开的文件中输入
/root
,搜索root关键字,按键盘上的n
键,会自动跳到下一个root的关键字,一直跳到这句话:
Allow root to run any commands anywhere
root ALL=(ALL) ALL
4.在刚行下增加你的用户名,保存退出
Allow root to run any commands anywhere
root ALL=(ALL) ALL
yourusername ALL=(ALL) ALL
参考:http://www.centoscn.com/CentOS/config/2016/0820/7816.html