天天看點

Centos 建立新的使用者并賦予sudo權限

centos建立新的使用者

useradd hadoop   #建立使用者
passwd hadoop   #設定密碼
           

建立使用者之後,可以進入到hadoop使用者下:

su hadoop
           

不過,剛建立的使用者,由于沒有在sudo使用者組中添權重限,是以當你使用sudo的時候會報錯,提示如下資訊:

hadoop is not in the sudoers file. This incident will be reported
           

是以,需要為hadoop使用者賦予sudo使用權限

為新使用者賦予sudo使用權限

首先,進入root使用者:

su root
           

然後,修改檔案權限:

chmod u+w /etc/sudoers
           

接着編輯/etc/sudoers檔案:

vi /etc/sudoers
           

在“ root ALL=(ALL) ALL” 這一行下面添加 “ xxx ALL=(ALL) ALL”(xxx就是剛建立的使用者名)

hadoop ALL=(ALL) ALL
           

也可以設定如下:

hadoop ALL=NOPASSWD:ALL
           

接着,儲存,先按ESC,鍵入“wq!”:

wq!
           

注:這個檔案是隻讀的,不加“!”儲存會失敗。

最後退出root使用者,一般情況你就可以正常的使用sudo指令了。

繼續閱讀