欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

给用户授权以root身份执行ls,touch,passwd命令,但是禁止修改root用户密码

程序员文章站 2022-07-14 19:57:37
...

通过visudo修改授权oldboy相关的权限

通过visudo修改授权oldboy相关的权限
[[email protected] ~]# visudo
oldboy  ALL=(ALL)       /bin/ls, /bin/touch, /usr/bin/passwd, !/usr/bin/passwd root



登录oldboy,并试验结果

登录oldboy,并试验结果
[[email protected] ~]# su - oldboy
[[email protected] ~]$ sudo passwd lin666
Changing password for user lin666.
New password: 
BAD PASSWORD: it is too simplistic/systematic
BAD PASSWORD: is too simple
Retype new password: 
passwd: all authentication tokens updated successfully.
[[email protected] ~]$ sudo passwd root
[sudo] password for oldboy: 
Sorry, user oldboy is not allowed to execute '/usr/bin/passwd root' as root on lin.

 

相关标签: linux 用户管理