max is not in the sudoers file.  This incident will be reported.

Posted in :

如何把一個使用者帳號加入到Linux管理者的群組裡.

 


先透過 useradd max

加了一組帳號叫 max

 

再透過 passwd max 設定了 max 的 password.

 

max 就可以透過 ssh 去登入server.

 

但 max 不是管理者,使用 sudo su 指令後會顯示 error:

[sudo] password for max: 

max is not in the sudoers file.  This incident will be reported.

 

用sudo時提示”xxx is not in the sudoers file. This incident will be reported.其中XXX是你的用戶名,也就是你的用戶名沒有權限使用sudo,我們只要修改一下/etc/sudoers文件就行了。


修改方法:

1)進入超級用戶模式。輸入:

su -

系統會讓你輸入超級用戶密碼,輸入密碼後就進入了超級用戶模式。(當然,你也可以直接用root用)

2)移除 sudoers文件的唯讀。輸入命令:

chmod u+w /etc/sudoers

3)編輯/etc/sudoers文件。輸入命令:

vi /etc/sudoers

輸入”i”進入編輯模式,找到這一 行:

root ALL=(ALL) ALL

在起下面添加

xxx ALL=(ALL) ALL

說明:(這裡的xxx是你的用戶名),然後保存(就是先按一 下Esc鍵,然後輸入”:wq”)退出。

4)撤銷文件的寫入權限。輸入命令:

chmod u-w /etc/sudoers

 

 

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *