sudo用戶的管理是在文件:/etc/sudoers中存放的。也就是說,如果想把某個用戶加入到sudo用戶群裡面,就需要自行配置這個文件,在讀寫這個文件時,需要root的權限。
[dba@oracle ~]$ sudo yum -y update We trust you have received the usual lecture from the local System Administrator. It usually boils down to these three things: #1) Respect the privacy of others. #2) Think before you type. #3) With great power comes great responsibility. [sudo] password for dba: dba is not in the sudoers file. This incident will be reported. [dba@oracle ~]$
使用 “su –” 命令,進入root用戶;為sudoers文件添加寫入的權限:使用命令 “chmod u+w /etc/sudoers”執行visudo 命令,按“i”進入編輯模式後,找到“root ALL=(ALL) ALL ”,在後面添加:"dba ALL=(ALL) NOPASSWD: ALL",再按一下“Esc”鍵退出編輯,輸入“wq”(write quit)後,退出sudoers。ss輸入“chmod u-w /etc/sudoers”將文件的寫入屬性去掉通過“exit”切換回自己的用戶,再使用sudo whoami命令時,如果返回root,就可以使用了