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” 錯誤解決方法

時報 nop nbsp 因此 文件 swd bsp user incident

CentOS6系統下,普通用戶使用sudo執行命令時報錯: xxx is not in the sudoers file.This incident will be reported"

解決方法就是在/etc/sudoers文件裏給該用戶添加權限。如下:

1.切換到root用戶下

2./etc/sudoers文件默認是只讀的,對root來說也是,因此需先添加sudoers文件的寫權限,命令是:
chmod u+w /etc/sudoers

3.編輯sudoers文件
vim /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

企業運維案例:xxx is not in the sudoers file.This incident will be reported” 錯誤解決方法