Linux中普通用戶用sudo執行命令時報”xxx is not in the sudoers file.This incident will be reported”錯誤,解決方法就是在/etc/sudoers文件里給該用戶添加權限。
如下:
1.切換到root用戶下
方法為直接在命令行輸入:su,然后輸入密碼(即你的登錄密碼,且密碼默認不可見)。
2./etc/sudoers文件默認是只讀的,對root來說也是,因此需先添加sudoers文件的寫權限,命令是:
即執行操作:chmod u+w /etc/sudoers
3.編輯sudoers文件
即執行:vi /etc/sudoers
找到這行 root ALL = (ALL) ALL,在他下面添加xxx ALL=(ALL) ALL (這里的xxx是你的用戶名)
4.撤銷sudoers文件寫權限,命令:
chmod u-w /etc/sudoers
5.切換用戶
su yakong