解決CentOS──xxx is not in the sudoers file方法

來源:互聯網
上載者:User

解決CentOS──xxx is not in the sudoers file方法
前陣子比較來比較去,選了CentOS作Linux系統,剛裝到虛擬機器裡面,發現預設的使用者無法開啟系統許可權。終端中輸入sudo後提示“XXX is not in the sudoers file. This incident will be reported.” 上網搜搜,找到瞭解決辦法:用sudo時提示"xxx is not in the sudoers file. This incident will be reported.其中XXX是你的使用者名稱,也就是你的使用者名稱沒有許可權使用sudo,我們只要修改一下/etc/sudoers檔案就行了。下面是修改方法:

1)進入超級使用者模式。也就是輸入"su -",系統會讓你輸入超級使用者密碼,輸入密碼後就進入了超級使用者模式。(當然,你也可以直接用root用)
2)添加檔案的寫入權限。也就是輸入命令"chmod u+w /etc/sudoers"。
3)編輯/etc/sudoers檔案。也就是輸入命令"vim /etc/sudoers",輸入"i"進入編輯模式,找到這一 行:"root ALL=(ALL) ALL"在起下面添加"xxx ALL=(ALL) ALL"(這裡的xxx是你的使用者名稱),然後儲存(就是先按一 下Esc鍵,然後輸入":wq")退出。


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

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.