环境:VMware下的CentOS
操作:
[[email protected] ~]$ sudo apt-get install samba <-----普通用户kiwi要进行sudo操作
[sudo] password for shaokn: <-----input passwd
kiwi is not in the sudoers file. This incident will be reported.
提示用户shaokn不在sudoers文件里.我们要做的就是把kiwi用户添加到sudoers文件里,怎么做呢?
1.进入超级用户模式.
[[email protected] ~]$ su -
Password: <-----input passwd
[[email protected] ~]# <-----root超级用户
2.添加sudoers文件写权限.
[[email protected] ~]# chmod u+w /etc/sudoers <-----注意sudoers文件路径
3.添加kiwi到sudoers文件里. 在"root ALL=(ALL) ALL"这行下添加"kiwi ALL=(ALL) ALL".
[[email protected] ~]# vim /etc/sudoers
.........................
.........................
root ALL=(ALL) ALL
kiwi ALL=(ALL) ALL <-----添加到这里. :wq保存退出
.........................
.........................
4.撤消sudoers写权限. 记得撤消写权限.
[[email protected] ~]# chmod u-w /etc/sudoers
通过以下4步,成功将kiwi这个用户添加到sudoers文件里,当然kiwi也获得了sudo权限.
转自: http://www.2cto.com/os/201304/203386.html
CentOS普通用户添加sudo权限