1. 程式人生 > >給使用者授權以root身份執行ls,touch,passwd命令,但是禁止修改root使用者密碼

給使用者授權以root身份執行ls,touch,passwd命令,但是禁止修改root使用者密碼

通過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.