CentOS下添加普通使用者到sudo組,並且免密碼登入

來源:互聯網
上載者:User

標籤:

1.1 sudo         Sudo是linux系統中,非root許可權的使用者提升自己許可權來執行某些特性命令的方式,它使普通使用者在不知道超級使用者的密碼的情況下,也可以暫時的獲得root許可權。
         一般,普通使用者在執行特殊命令是,只需要在特殊命令(如 yum)前面加上sudo,並輸入自己的使用者密碼就可以了,在之後的5分鐘內,再次使用特殊命令時,就無需再次輸入使用者密碼。
         同時,sudo提供了強大的日誌管理,其中詳細的記錄了每個使用者都幹了什麼。

         sudo使用者的管理是在檔案:/etc/sudoers中存放的。也就是說,如果想把某個使用者加入到sudo使用者群裡面,就需要自行配置這個檔案,在讀寫這個檔案時,需要root的許可權。

1.2 將使用者添加到sudo組         在使用sudo的時候,如果出現"dba is not in the sudoers file. This incident will be reported.”說明目前使用者名:dba是沒有許可權使用sudo的,這個時候我們就需要修改/etc/sudoers來為目前使用者dba添加sudo許可權。

[[email protected] ~]$ sudo yum -y updateWe trust you have received the usual lecture from the local SystemAdministrator. It usually boils down to these three things:    #1) Respect the privacy of others.    #2) Think before you type.    #3) With great power comes great responsibility.[sudo] password for dba: dba is not in the sudoers file.  This incident will be reported.[[email protected] ~]$ 

  1. 使用 “su –” 命令,進入root使用者;
  2. 為sudoers檔案添加寫入的許可權:使用命令   “chmod u+w /etc/sudoers”
  3. 執行visudo 命令,按“i”進入編輯模式後,找到“root ALL=(ALL) ALL ”,在後面添加:"dba ALL=(ALL)  NOPASSWD:  ALL",再按一下“Esc”鍵退出編輯,輸入“wq”(write quit)後,退出sudoers。ss
  4. 輸入“chmod u-w /etc/sudoers”將檔案的寫入屬性去掉
  5. 通過“exit”切換回自己的使用者,再使用sudo  whoami命令時,如果返回root,就可以使用了

CentOS下添加普通使用者到sudo組,並且免密碼登入

聯繫我們

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