close

如何加入新的帳號

如果你是用root:

adduser sammy

如果你是不是root 請給予sudo

sudo adduser sammy

當你執行這個指令後,你將會看到螢幕上有一系列的資訊分配和確認密碼,

然後你會看到一些額外的訊息關於新的使用者你可以按下Enter乎略這些訊息,

最後他將會問你這些訊息是否正確請選擇y, 如下圖:

 
Output

Adding user `sammy' ...

Adding new group `sammy' (1001) ...

Adding new user `sammy' (1001) with group `sammy' ...

Creating home directory `/home/<^>sammy' ...

Copying files from `/etc/skel' ...

Enter new UNIX password:

Retype new UNIX password:

passwd: password updated successfully

Changing the user information for sammy

Enter the new value, or press ENTER for the default

              Full Name []:

              Sammy the Shark Room Number []: 123

              Work Phone []: 555-555-5555

              Home Phone []:

              Other []:

Is the information correct? [Y/n] y

 

如何受予使用者sudo權限

新增一個新的使用者到sudo 群組,Debian 8系統是配置沿伸最高權根到任何使用者是在 sudo 群組

你可以看你新增使用者的groups使用groups命令

 

$groups sammy

Output

sammy : sammy

在預訊下,新的使用者只有在他們自已group,為了加入一個使用者到新的群組你可以使用 usermod  命令:

$usermod -aG sudo sammy

這裡的-aG選項是告訴usermod新增使用者到這個群組列

你可以查在一次查看groups命令將會看到你的使用者已加入sudo群組

 
Output

sammy : sammy sudo

 

現在你的使用都已經可以使用管理權根,當你登入sammy你將提示輸入密碼時,請輸入sammy的密碼非root 的密碼

 

指定明確的使用者特權在 /etc/sudoers(與上一個方法效果一樣)

這是一個另類將使用者放入sudo 群組的方法,你可以使用visudo命令,電腦將呼叫檔案/etc/sudoers

如果你是使用root登入:

#visudo

如果你非使用root登入請加上sudo:

$sudo visudo

傳統上,visudo開啟/etc/sudoers在vi編譯,但新版的Debian預設為nano

                                                                      

                                                                                    /etc/sudoers                                                                                                   
root    ALL=(ALL:ALL) ALL

複製下面這條線的格式,然後將他貼上於下方並將root更改於你要設定的使用者

                                                                                   /etc/sudoers                                                                                                     
root    ALL=(ALL:ALL) ALL
sammy ALL=(ALL:ALL) ALL

 

如何刪除使用者

你可以刪除使用者本身,以root帳號登入:

# deluser sammy

非root帳號登入

$ sudo deluser sammy

 

如果你想刪除這個使用者的home資料夾當這個使用都被刪除後,以root帳號登入:

# deluser --remove-home sammy

非root帳號登入:

$ sudo deluser --remove-home sammy

 

如果你之前有在/etc/sudoers 或visudo編譯記得要刪除

Output

root ALL=(ALL:ALL) ALL

sammy ALL=(ALL:ALL) ALL # DELETE THIS LINE

arrow
arrow

    wealthy 發表在 痞客邦 留言(0) 人氣()