max is not in the sudoers file. This incident will be reported.
阿新 • • 發佈:2018-12-27
如何把一個使用者帳號加入到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