1 / 28

使用者帳號管理與群組管理

使用者帳號管理與群組管理. 使用者帳號管理. 新增使用者帳號 密碼 使用者資訊 移除使用者帳號. Add user. 系統中的使用者帳號必須是唯一的 新增使用者帳號之前請確定要建立的新帳號是否已經有同名的使用者 檢查方法 finger 檢查 /etc/passwd 檔. / etc/passwd. more /etc/passwd “ root:x:0:0:root:/root:/bin/bash” 使用者 root 之設定

todd-hinton
Download Presentation

使用者帳號管理與群組管理

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 使用者帳號管理與群組管理

  2. 使用者帳號管理 • 新增使用者帳號 • 密碼 • 使用者資訊 • 移除使用者帳號

  3. Add user • 系統中的使用者帳號必須是唯一的 • 新增使用者帳號之前請確定要建立的新帳號是否已經有同名的使用者 • 檢查方法 • finger • 檢查 /etc/passwd 檔

  4. /etc/passwd • more /etc/passwd • “root:x:0:0:root:/root:/bin/bash” • 使用者 root 之設定 • 第一個是使用者名稱﹐然後在第一個和第二個‘﹕’之間﹐是使用者密碼﹐但因為是經過加密的﹐所以您只能看到“x”(如果被修改成空白﹐就表示沒用使用密碼)﹔然後是兩個“0”﹐分別是user ID 和 group ID • 接下來的是一些使用者資料﹐和其主目錄所在﹐以及登錄時候要使用的shell。

  5. /etc/passwd • 您可以直接用 vim 來增加和指定或修改使用者帳號﹐然後執行 pwconv 程式更新 /etc/shadow檔案。 • pwunconv停止保護

  6. 建立帳號Add user • adduser = useradd • adduser • 在/etc/passwd加入新帳號相關資料 • 在/etc/group加入新使用者起始群組 • 建立使用者的home directory • 將自動複製/etc/ske1目錄中的設定檔到使用者的HOME目錄中 • passwd • 建立使用者的密碼

  7. useradd • 如果您不理會group和ID等因素﹐只想建立一個使用者帳號的話您可以使用﹕ • useradd user1 • 不帶任何參數就可以了﹐這樣user﹐group的ID都會被自動建立起來的。 • 預設UID 500, 預設GID UPG • 密碼欄中 !! 表示未設定密碼

  8. useradd • 建立一個群組為user1的帳號 useradd –g user1 user2

  9. useradd • useradd -u 1001 -g 1001 user3 • 這樣我們就可以建立起一個名叫‘user3’的使用者帳號了﹐他的user ID為1001﹐指定的 group ID 為1001。 • 使用 useradd 來建立使用者的話﹐其家目錄和郵件信箱等相關資料也會被建立起來﹐也就省去了手工設定的麻煩了。

  10. 設定密碼 • 您還得在此為使用者指定一個密碼 • passwd user1 • 您需要輸入密碼兩次才能完成這個動作 • 只有系統管理員才可以指定別人的密碼 • 以後﹐當使用者成功登錄之後﹐他/她可以使用‘passwd’不帶任何參數﹐來修改自己的密碼。

  11. 刪除使用者密碼 • passwd –d user1

  12. 檢視使用者資訊 finger • % finger Login Name TTY Idle When Where umi3432 8323032 p0 Thu 19:30 140.125.250.60 umi4202 8423302 p1 1:58 Thu 17:35 140.125.200.208 umi4256 ??? p2 17 Thu 17:26 140.125.202.8 umi3437 8323037 p3 45 Thu 18:32 140.125.201.131 umi4211 8423311 p4 2:46 Thu 16:15 140.125.201.242 umi4244 8423344 p5 Thu 19:07 140.125.201.186

  13. finger • finger username • % finger melanie Login name: melanie In real life: Chi-Meei Yang Directory: /sun4330/melanie Shell: /bin/csh On since Nov 7 19:30:47 on ttypf from 140.125.83.140 Project: NYIT MIS department Plan:Study sendmail 8.8

  14. finger不輸出.project .plan檔案 Login name: melanie In real life: Chi-Meei Yang Directory: /sun4330/melanie Shell: /bin/csh On since Nov 7 19:30:47 on ttypf from 140.125.83.140 16 seconds Idle Time No unread mail % finger -p melanie

  15. finger指令參考下檔案 • /etc/utmp who is logged in • /etc/passwd for users' names • /var/adm/lastlog last login times • /etc/ttytab terminal locations • 在個人home directory下建立 • .plan 可容納多行資料 • .project 只可以一行資料

  16. 修改使用者資訊 • chfn • chfn name

  17. 修改帳號相關設設 • usermod • 只有root可使用

  18. 停用使用者帳號 • 暫時停止 • 移除帳號但保留檔案 • 完全移除帳號及所有檔案

  19. 暫時停用使用者帳號 • 若想暫時停用某帳號﹐可以直接修改 /etc/passwd 檔﹐然後在該帳號前面加上一個“#”符號 • 我們通常使用‘#’將句子標記起來﹐這樣﹐系統只會把該行視作‘註解’﹐而不會執行其設定內容了。 • 在密碼欄加上 “ *”

  20. 暫時停用使用者帳號 • 鎖住密碼 passwd –l user1 • 解除密碼 passwd –u user1

  21. 刪除使用者帳號 • 直接在passwd檔中將該使用者的資訊整行刪除 • 不保留該使用者檔案 • 手動刪除該使用者檔案 • 保留該使用者檔案 • 移動檔案位置 • 使用chown更改檔案所有檔案

  22. 刪除使用者帳號 • userdel -r test1 • 就可以將其帳號和主目錄清除掉了 • 但如果該使用者使用過郵件信箱的話﹐我們就得手工的將其信箱移除了 • rm -rf /var/spool/mail/test1

  23. 使用 root • su - • su 不帶‘-’的話﹐root 的一些環境設定可能不會生效 • 入 root 的密碼﹐您就可以轉變成 root 的身份了。 • 當完成了系統設置之後﹐您可以輸入‘exit’跳離 root 的身份﹐回到自己的身份。這樣做完全是基於安全考量

  24. 增加群組 • 群組資料存放在/etc/group檔案中 users::100: user1,user2 • group name,group ID﹐兩者都必須是唯一的。 • user1,user2為群組users的成員 • 可使用 vim 對這個檔進行編輯來增加群組

  25. 新增群組groupadd • groupadd -g 1001 group1 • 通常﹐我們自定的群組ID都由500開始﹐不過﹐也不是一定如此﹐只是管理的條理化需要而已。 • 上面這個命令﹐我們為 /etc/group 增加了一個ID為1001的 group1 群組。

  26. 群組資訊 • 修改群組users的資料 groupmod users

  27. 移除群組 • 刪除users群組 groupdel users

  28. 管理群組 • 只有root或群組管理者可使用 • 設定群組密碼 gpasswd users • 取消群組密碼 gpasswd –r users • 加入成員 gpasswd -a user3 • 移除成員 gpasswd –d user3

More Related