给普通用户sudo的权限

系统环境:CENTOS7

useradd student

passwd student

设置好密码

[root@V71 ~]# visudo

打开文件加上student这一行,即可完成sudo授权

## Allow root to run any commands anywhere
root    ALL=(ALL)       ALL
student    ALL=(ALL)       ALL

改成如下一行可免输入该用户的密码执行sudo命令,适用于通过堡垒机登录的用户

student    ALL=(ALL)    NOPASSWD:ALL    

 

切换到用户student测试

扫描二维码关注公众号,回复: 3540329 查看本文章

[root@V71 ~]# su - student
上一次登录:一 10月  8 17:30:46 CST 2018pts/0 上
[student@V71 ~]$ 

[student@V71 ~]$ sudo mkdir /studenttest

输入student登陆密码以后在根目录新建文件夹成功,以root的身份创建,说明sudo授权成功

[student@V71 ~]$ ls -ld /studenttest/
drwxr-xr-x 2 root root 6 10月  8 17:41 /studenttest/

猜你喜欢

转载自blog.csdn.net/lsysafe/article/details/82971217