本文介紹了在Ubuntu使用過程中遇到 is not in the sudoers file 時的解決辦法。
用sudo時提示"xxx is not in the sudoers file. This incident will be reported.其中XXX是你的用戶名,也就是你的用戶名沒有權(quán)限使用sudo,我們只要修改一下/etc/sudoers文件就行了。
例子:
www_linuxidc_com@linuxidc-Aspire-3680:~$ sudo add-apt-repository ppa:stk/dev
[sudo] password for www_linuxidc_com:
www_linuxidc_com is not in the sudoers file. This incident will be reported.
www_linuxidc_com@linuxidc-Aspire-3680:~$
下面是解決方法:
1)進(jìn)入超級用戶模式。也就是輸入"su -",系統(tǒng)會讓你輸入超級用戶密碼,輸入密碼后就進(jìn)入了超級用戶模式。(當(dāng)然,你也可以直接用root用)
(注意有- ,這和su是不同的,在用命令”su”的時候只是切換到root,但沒有把root的環(huán)境變量傳過去,還是當(dāng)前用戶的環(huán)境變量,用”su -”命令將環(huán)境變量也一起帶過去,就象和root登錄一樣)
2)添加文件的寫權(quán)限。也就是輸入命令"chmod u+w /etc/sudoers"。
3)編輯/etc/sudoers文件。也就是輸入命令"gedit /etc/sudoers",進(jìn)入編輯模式,找到這一 行:"root ALL=(ALL) ALL"在起下面添加"www_linuxidc_com ALL=(ALL) ALL"(這里的xxx是你的用戶名),然后保存退出。
4)撤銷文件的寫權(quán)限。也就是輸入命令"chmod u-w /etc/sudoers"。