Ubuntu新添加使用者無法sudo問題的解決:修改sudoers

來源:互聯網
上載者:User

 

Ubuntu新添加的hadoop使用者無法通過sudo執行命令,提示:

 

hadoop is not in the sudoers file...

 

 

解決這個問題只需要切換到其他可以執行sudo的使用者,修改/etc/sudoers檔案即可,但是這個檔案的修改要很小心,它預設的許可權為440,所以要改許可權,修改完檔案再把許可權改回去

 

改權sudoers檔案的許可權時要注意:

 

用sudo su -徹底切換到root,否則是不行滴

 

執行命令如下:

 

$ sudo su - 

# chmod a+w /etc/sudoers 

# vi /etc/sudoers 

# chmod a-w /etc/sudoers 

$ sudo su -

# chmod a+w /etc/sudoers

# vi /etc/sudoers

# chmod a-w /etc/sudoers

其中vi /etc/sudoers之後,需要在root ALL(ALL) ALL一行之後加上:

 

hadoop ALL(ALL) ALL

 

儲存退出即可,其中hadoop是需要授予sudo執行許可權的使用者名稱

 

修改sudoers檔案的另外一個方法是網上很多地方都有的:

 

重啟Ubuntu,按Esc或者Shift鍵進入grub的引導菜單,選擇進入recovery mode,進入後選擇root登入,便可以修改sudoers檔案的許可權

 

如果系統上的所有使用者都用不了sudo的話也只好用這種辦法了

作者 bhq2010

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.