1. 程式人生 > >xxx is not in the sudoers file.This incident will be reported.的解決方法

xxx is not in the sudoers file.This incident will be reported.的解決方法

通常我們在Linux中自己通過指令新建立的使用者,如果沒有分配使用者組的話,就沒有辦法使用sudo命令,這樣在操作的過程中會有很多的不便。

並且會報錯

<span style="font-family:Microsoft YaHei;font-size:12px;">xxx is not in the sudoers file.This incident will be reported.</span>

解決辦法如下:

1.切換到root使用者下,怎麼切換就不用說了吧,不會的自己百度去.



2.新增sudo檔案的寫許可權,命令是:
chmod u+w /etc/sudoers


3.編輯sudoers檔案
vi /etc/sudoers
找到這行 root ALL=(ALL) ALL,在他下面新增xxx ALL=(ALL) ALL (這裡的xxx是你的使用者名稱)


ps:這裡說下你可以sudoers新增下面四行中任意一條
youuser            ALL=(ALL)                ALL
%youuser           ALL=(ALL)                ALL
youuser            ALL=(ALL)                NOPASSWD: ALL
%youuser           ALL=(ALL)                NOPASSWD: ALL


第一行:允許使用者youuser執行sudo命令(需要輸入密碼).
第二行:允許使用者組youuser裡面的使用者執行sudo命令(需要輸入密碼).
第三行:允許使用者youuser執行sudo命令,並且在執行的時候不輸入密碼.
第四行:允許使用者組youuser裡面的使用者執行sudo命令,並且在執行的時候不輸入密碼.


4.撤銷sudoers檔案寫許可權,命令:
chmod u-w /etc/sudoers


這樣普通使用者就可以使用sudo了.