CentOS普通用户添加sudo权限

来源:互联网 发布:php.ini file uploads 编辑:程序博客网 时间:2024/04/30 02:01
环境:VMware下的CentOS
操作:
[shaon@localhost ~]$ sudo apt-get install samba   <-----普通用户shaokn要进行sudo操作
[sudo] password for shaokn:            <-----input passwd
shaokn is not in the sudoers file. This incident will be reported.
提示用户shaokn不在sudoers文件里.我们要做的就是把shaokn用户添加到sudoers文件里,怎么做呢?

我是按这里http://blog.sina.com.cn/s/blog_697c002f0100mkq5.html的操作来的.
1.进入超级用户模式.
[shaon@localhost ~]$ su -     
Password:                   <-----input passwd 
[root@localhost ~]#         <-----root超级用户

2.添加sudoers文件写权限. 
[root@localhost ~]chmod u+w /etc/sudoers  <-----注意sudoers文件路径

3.添加shaokn到sudoers文件里. 在"root ALL=(ALL) ALL"这行下添加"shaokn ALL=(ALL) ALL".
[root@localhost ~]# vim /etc/sudoers
.........................
.........................
root    ALL=(ALL)   ALL
shaokn  ALL=(ALL)   ALL   <-----添加到这里. :wq保存退出
.........................
.........................

4.撤消sudoers写权限. 记得撤消写权限.
[root@localhost ~]chmod u-w /etc/sudoers

通过以下4步,成功将shaokn这个用户添加到sudoers文件里,当然shaokn也获得了sudo权限.
0 0
原创粉丝点击