使用者不在sudoers檔案中的解決方案

來源:互聯網
上載者:User

    在使用Linux系統過程中,通常情況下,我們都會使用普通使用者進行日常操作,而root使用者只有在許可權分配及系統設定時才會使用,而root使用者的密碼也不可能公開。普通使用者執行到系統程式時,需要臨時提升許可權,sudo就是我們常用的命令,僅需要輸入目前使用者密碼,便可以完成許可權的臨時提升。在使用sudo命令的過程中,我們經常會遇到目前使用者不在sudoers檔案中的提示資訊,如果解決該問題呢?通過下面幾個步驟,可以很簡單的解決此問題。

    1、切換到root使用者權限

Last login: Tue Sep 24 20:50:51 2013 from 192.168.30.171
[user@Compile ~]$ su root
密碼:
[root@Compile user]#

    2、查看/etc/sudoers檔案許可權,如果唯讀許可權,修改為可寫入權限

[root@Compile user]# ls -l /etc/sudoers
-r--r-----. 1 root root 4030 9月  25 00:57 /etc/sudoers
[root@Compile user]# chmod 777 /etc/sudoers
[root@Compile user]# ls -l /etc/sudoers
-rwxrwxrwx. 1 root root 4030 9月  25 00:57 /etc/sudoers
[root@Compile user]#

    3、執行vi命令,編輯/etc/sudoers檔案,添加要提升許可權的使用者;在檔案中找到root

root    ALL=(ALL)       ALL
user    ALL=(ALL)       ALL

說明:格式為(使用者名稱    網路中的主機=(執行命令的目標使用者)    執行的命令範圍)

    4、儲存退出,並恢複/etc/sudoers的存取權限為440

[root@Compile user]# chmod 440 /etc/sudoers
[root@Compile user]# ls -l /etc/sudoers
-r--r-----. 1 root root 4030 9月  25 00:57 /etc/sudoers
[root@Compile user]#

    5、切換到普通使用者,測試使用者權限提升功能

 

聯繫我們

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