xx is not in the sudoers file 问题解决
原文:http://blog.sina.com.cn/s/blog_4ef045ab0100j59t.html
我用的是redhat5.4,在一般用戶下執行sudo命令提示llhtiger is not in the sudoers file. This incident will be reported.解決方法:
一、$whereis sudoers -------找出文件所在的位置,默認都是/etc/sudoers?
二、 #chmod u+w /etc/sudoers? 以超級用戶登錄su -root ,修改文件權限即添加文件擁有這的寫權限 限,ls -al /etc/sudoers 可以查看原文件的權限。?
三、vim /etc/sudoers 編輯文件,在root ALL=(ALL)ALL行下添加XXX ALL=(ALL)ALL,XXX為你的用戶名。添加方法:找到root行,按下”i“鍵進入編輯模式添加即可!編輯好后esc鍵進入一般模式,“:wq"保存退出!
最后, #chmod u-w /etc/sudoers 回到文件的原權限!
下面這個稍微詳細一點:
在ubuntu中由于禁用了root用戶,默認情況下會把安裝系統時建立的用戶添加到sudoers中。但在redhat和centos中并沒有把任何root用戶之外的用戶默認的添加到sudoers之中。這樣我們在執行sudo 命令時就會出現xxx is not in the sudoers file. This incident will be reported.這樣的錯誤輸出?,F在為了安全起見比較提倡使用普通用戶做日常操作,而在需要超級用戶的時候使用sudo 來做,這樣,我們就有必要把一些用戶添加到sudoers之中。
其實把用戶添加到sudoers之中很簡單。
首先利用whereis 命令查找sudoers配置文件的目錄(默認會在/etc/sudoers)
[root@localhost xiaofei]# whereis sudoers
sudoers: /etc/sudoers /etc/sudoers.bak /usr/share/man/man5/sudoers.5.gz
然后需要切換到root用戶,更改/etc/sudoers的權限
[root@localhost xiaofei]# chmod u+w /etc/sudoers
然后就可以利用vi編輯器來把用戶添加到sudoers之中
[root@localhost xiaofei]# vi /etc/sudoers
然后找到root? ALL=(ALL)? ALL所在的位置,把所要添加的用戶添加到文件之中,
順便提一下vi編輯器的用法。剛進入vi編輯器的時候牌命令行模式,這時可以通過方向鍵來移動光標,找到要編輯的位置之后按下“i”,然后就進入了插入模式,這時候你可以輸入或刪除字符。編輯完成之后按“esc”鍵退出插入模式,進入命令行模式,這時候按“:”可以進入末行模式,輸入“wq”保存并退出。
下面是添加完的結果。
## Allow root to run any commands anywhere
root? ALL=(ALL)? ALL
xiaofei ALL=(ALL)? ALL? (這一行是添加的內容,xiaofei是我的用戶名)
然后需要把sudoers 的寫權限去掉(否則系統不允許執行suoders文件):
[root@localhost xiaofei]# chmod u-w /etc/sudoers
至此,在退出root用戶之后就可以利用sudo命令來執行超級用戶的權限了。
原文:http://www.wongkey.com/archives/linux-sudoers
轉載于:https://www.cnblogs.com/tianshangrenjian/archive/2013/03/17/2964115.html
總結
以上是生活随笔為你收集整理的xx is not in the sudoers file 问题解决的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 马桶冲水慢无力没漩涡怎么办?
- 下一篇: 达州市电力集团书记是什么级别