====== 維護伺服器存取權限 ====== ===== 使用者 ===== **我如何看到系統內的使用者列表清單?** 您可以在 /etc/passwd 這個檔案內看到這台伺服器的使用者清單,請輸入下列指令查看: cat /etc/passwd 你會看到很像如下的結果: eric:x:1006:1006::/home/eric:/bin/sh john:x:1007:1007::/home/john:/bin/sh sibelius:x:1007:1007::/home/sibelius:/bin/sh ==== 變更您的密碼 ==== 要變更您的密碼,請先使用您的帳號登入伺服器內(假設是 root),然後輸入下列指令: passwd 接下來您需要輸入新密碼。在提示符號後面輸入: Enter new UNIX password: ...請再輸入一次密碼來確認: Retype new UNIX password: 如果您輸入兩次相同的密碼,你將可以看到下列成功訊息: passwd: password updated successfully ==== 使用 root 來變更其他使用者的密碼 ==== 如果您是使用 'root' 登入伺服器並且您想要變更其他使用者的密碼,請輸入下列指令(假設 billy 是其中一個使用者): passwd billy 您會被要求輸入密碼與再次輸入來確認密碼: Enter new UNIX password: Retype new UNIX password: 如果成功,您將會看到下列訊息: passwd: password updated successfully ==== 建立其他使用者 ==== 為了讓其他人能夠登入您的主機,你需要幫他們建立使用者帳號。請在命力提示符號後面輸入下列指令(請將 freya 替換成您要建立的帳號名稱): adduser freya 如下,系統將會詢問您幾個問題,簡易回答這些問題即可: Adding user `freya' ... Adding new group `freya' (1004) ... Adding new user `freya' (1005) with group `freya' ... Creating home directory `/home/freya' ... Copying files from `/etc/skel' ... Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully Changing the user information for freya Enter the new value, or press ENTER for the default Full Name []: freya freyasson Room Number []: Work Phone []: Home Phone []: Other []: my cat Is the information correct? [y/N] y ==== 刪除使用者 ==== 要刪除您的使用者帳號,請在命令提示符號後面輸入如下指令(請將 phil 替換成您要刪除的帳號): userdel -r phil 注意: 使用 -r 選項將會移除使用者家的家目錄與所有檔案,包含使用者的郵件。 ===== 群組 ==== ===== 建立群組 ===== 要建立群組,請在命令提示符號後面出入下列的指令(請將 friends 替換成您要建立的群組名稱): groupadd friends ===== 管理使用者群組 ===== ==== 將使用者增加到群組 ==== === 在建立使用者的時候 === 在建立使用者的時候可以直接將他加入其他群組內,請在命力提示符號後面輸入以下指令(請將 'friends' 更換成您的群組,'eric' 更換成您的使用者): useradd -g friends eric (您可以參考 man useradd 來查詢其他選項) === 在使用者已經存在時 === usermod -g friends eric (您可以參考 man useradd 來查詢其他選項)