Debian中設定sudo

來源:互聯網
上載者:User

 安裝好Debian後還不能使用sudo
如果沒有安裝sudo,則在root使用者下apt-get install sudo
在root設定sudoers配製檔案
chmod +w /etc/sudoers
vim /etc/sudoers
添加一行   username     ALL=(ALL) ALL
其中username是你的使用者名稱,儲存
更改sudoers檔案許可權  chmod 0440 /etc/sudoers
退出root
轉貼自:http://blog.chinaunix.net/u1/51074/showart_429833.html
方法二: 7 、 把你安裝時建立的那個使用者加入sudoers
visudo
在 root ALL=(ALL) ALL 下面加入
%adm ALL=(ALL) ALL
然後執行 gpasswd -a username adm

又是一貼,轉 自:http://www.linux-wiki.cn/index.php/%E6%B7%BB%E5%8A%A0sudoer

使用sudo可以在以非root使用者登入時臨時獲得root許可權,並執行需要的命令。

 

可以使用sudo的使用者可以叫做sudoer。

添加sudoer的方法(假設您已經安裝sudo):

執行

# visudo

# sudoedit

提示:
有些發行版的sudo提供了sudoedit,有的則提供了visudo,功能上基本是一樣的。你也可以使用其他編輯器如vi進行編輯/etc/sudoers,但由於檔案是唯讀,請強制儲存(如w!)或去除唯讀屬性再儲存。

尋找

root ALL=(ALL) ALL

在下面加入

%adm ALL=(ALL) ALL

如果sudo時不想輸入密碼,可以把上句改成:

%adm ALL=(ALL) NOPASSWD: ALL

儲存檔案,然後執行

#gpasswd -a 使用者名稱 adm

然後這個使用者就可以用sudo了。

       為了日常使用安全,非必要時候不用root這個賬戶的習慣是非常重要的,可以用sudo這個來代替,這樣不僅僅所有的設定檔都是目前使用者的,連根目錄也是,但是最近發現,使用sudo也出現一個小問題。我們都知道linux下tab鍵的自動補全功能是非常強大的,可是我發現使用sudo以後,tab鍵就變傻了。除了能補全路徑以外,對命令完全沒有作用,好在現在已經知道原因了。
       在.bashrc這個檔案裡需要設定一下。
# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profiles
# sources /etc/bash.bashrc).
#if [ -f /etc/bash_completion ]; then
#         . /etc/bash_completion
#fi
        這是最後的幾行,把最後面三行前面的#去掉,然後重新登陸就可以拉,呵呵。
轉貼自:http://www.i170.com/Article/48420

聯繫我們

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