歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> Ubuntu技巧之 is not in the sudoers file解決方法

Ubuntu技巧之 is not in the sudoers file解決方法

日期:2017/2/28 16:26:51   编辑:Linux教程
本文介紹了在Ubuntu使用過程中遇到 is not in the sudoers file 時的解決辦法。

用sudo時提示"xxx is not in the sudoers file. This incident will be reported.其中XXX是你的用戶名,也就是你的用戶名沒有權限使用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)進入超級用戶模式。也就是輸入"su -",系統會讓你輸入超級用戶密碼,輸入密碼後就進入了超級用戶模式。(當然,你也可以直接用root用)
(注意有- ,這和su是不同的,在用命令”su”的時候只是切換到root,但沒有把root的環境變量傳過去,還是當前用戶的環境變量,用”su -”命令將環境變量也一起帶過去,就象和root登錄一樣)

2)添加文件的寫權限。也就是輸入命令"chmod u+w /etc/sudoers"。
3)編輯/etc/sudoers文件。也就是輸入命令"gedit /etc/sudoers",進入編輯模式,找到這一 行:"root ALL=(ALL) ALL"在起下面添加"www_linuxidc_com ALL=(ALL) ALL"(這裡的xxx是你的用戶名),然後保存退出。

4)撤銷文件的寫權限。也就是輸入命令"chmod u-w /etc/sudoers"。

Copyright © Linux教程網 All Rights Reserved