場景:
在CentOS中建立了一個新用戶user,在調用sudo命令時,報:「user is not in the sudoers file. This incident will be reported」 錯誤,沒法執行sudo命令。 shell
分析:
在ubuntu中因爲禁用了root用戶,默認狀況下會把安裝系統時創建的用戶添加到sudoers中。但在redhat和centos中並無把任何root用戶以外的用戶默認的添加到sudoers之中。這樣咱們在執行sudo 命令時就會出現xxx is not in the sudoers file. This incident will be reported.這樣的錯誤輸出。如今爲了安全起見比較提倡使用普通用戶作平常操做,而在須要超級用戶的時候使用sudo 來作,這樣,咱們就有必要把一些用戶添加到sudoers之中。 ubuntu
解決:
centos
#chmod u+w /etc/sudoers #vi /etc/sudoers 在root ALL=(ALL)ALL行下添加XXX ALL=(ALL)ALL,XXX爲你的用戶名 #chmod u-w /etc/sudoers