SlideShare a Scribd company logo
1 of 28
User Management
CSIE 基爾 @ NCU網路開源社
Updated: 12082013
課程
• 相關學分:計算機概論、作業系統
• 等級:
• 背景知識:
• 課程目標:
• 了解使用者管理
• 了解SUDO
Multi-user
Operating System
Unix-OS
• 多人同時使用的作業系統
• Windows一般不允許這麼做
UID / GID
• 群組編號:GID
• 使用者編號:UID
• 0 : 系統管理者
• 1~499:系統帳號
• Other:一般user
*電腦是認「編號」的,所以會有設定檔存放「名稱」。
*如果檔案在伺服器「間」搬動時,可能會遺失「名稱」。
使用者管理
• 系統使用者設定檔:/etc/passwd
• 檔案結構:
*有顯示密碼的檔案:
/etc/master.passwd
帳號
密碼 – 被屏障
UID
GID
Class
Change
Expired
Full name
家目錄
Login Shell
群組管理
• /etc/group
• GID與UID的對應
• 檔案結構 群組名稱
群組密碼
GID
群組內帳號
檔案關係(BY Vbird)
/etc/master.passwd
帳號管理
新增使用者
• 指令:adduser
• 幾個重點
• Username: 使用者名稱
• Enter password: 使用者密碼
事實上其他都用預設就好,Linux部分版本已經全部省略。
指令adduser做了下面幾件事情
在 /etc/group 中加入使用者的群組
在 /etc/master.passwd 中加入使用者
在 /home 中建立使用者目錄,並建立 dotfile
在 /var/mail 中建立使用者郵件目錄
刪除使用者
• 指令:rmuser [username]
指令rmuser做了下面幾件事情
如果有定期排程,移除排程
如果該使用者正在執行程式,關閉程式
移除 /etc/master.passwd 中的帳號
移除使用者家目錄
移除郵件目錄
移除暫存檔
如果群組為空,移除群組
• 指令: passwd [username]
*填空白是改自己的密碼
修改使用者密碼
家目錄
*除了root外,通常一般使用者的家目錄都在/home底下
• /root
• /home/[username]
• 家目錄就如同windows的桌面。
• 通常客製化的設定檔可以放在這邊,如同windows的AppData。
新增群組
• 指令:pw groupadd [groupname]
*當然這可以拿來新增使用者~
Substitute User Identity
實作要點
• 請注意自己是誰?
• 先使用root登入本機,做好使用者的控管。
• 在使用一般user透過ssh登入。
• 登入之後,使用su,sudo等指令check是否成功。
whoami / groups
• 確認自己的身分,所屬的群組。
su
• 這是內建的指令,用來轉換使用者身分。
• su – [username]
• 輸入之後,要輸入「對方的密碼」進行轉換。
sudo
• 這在freebsd上面並不是內建的指令。
• 用來轉換身分,但是跟su有很大的不同。
1. 他有log檔案,能夠紀錄sudo後的每一個系統動作
2. 他輸入的密碼是「自己的密碼」
3. 使用者必須在「欲轉換對象的群組內」
因為課程順序安排,已經先將sudo安裝至系統中。
不管sudo,還是su。
他們都不只是為了有root權限而存在的。
@交大丁組2013筆試
sudo運用:提升至root權限
1. 開啟wheel群組功能
設定檔位置:/usr/local/etc/sudoers
移除「#%wheel ALL=(ALL) ALL」的註解
sudo運用:提升至root權限
2. 將自己加入 /etc/group 檔案中的 wheel 群組中
sudo運用:查看log檔
3. 查看message記錄檔,追究責任
記錄檔位置:/var/log/message
*你逃不掉的!
• 沒下過***指令,不要說你用過Unix系列作業系統
Login Session
Shell
• By Vbird
command shell process

More Related Content

More from Kir Chou

Learn from LL(1) to PEG parser the hard way
Learn from LL(1) to PEG parser the hard wayLearn from LL(1) to PEG parser the hard way
Learn from LL(1) to PEG parser the hard wayKir Chou
 
Time travel: Let’s learn from the history of Python packaging!
Time travel: Let’s learn from the history of Python packaging!Time travel: Let’s learn from the history of Python packaging!
Time travel: Let’s learn from the history of Python packaging!Kir Chou
 
Python パッケージの影響を歴史から理解してみよう!
Python パッケージの影響を歴史から理解してみよう!Python パッケージの影響を歴史から理解してみよう!
Python パッケージの影響を歴史から理解してみよう!Kir Chou
 
The str/bytes nightmare before python2 EOL
The str/bytes nightmare before python2 EOLThe str/bytes nightmare before python2 EOL
The str/bytes nightmare before python2 EOLKir Chou
 
PyCon TW 2018 - A Python Engineer Under Giant Umbrella (巨大保護傘下的 Python 碼農辛酸史)
PyCon TW 2018 - A Python Engineer Under Giant Umbrella (巨大保護傘下的 Python 碼農辛酸史) PyCon TW 2018 - A Python Engineer Under Giant Umbrella (巨大保護傘下的 Python 碼農辛酸史)
PyCon TW 2018 - A Python Engineer Under Giant Umbrella (巨大保護傘下的 Python 碼農辛酸史) Kir Chou
 
Introduction of CTF and CGC
Introduction of CTF and CGCIntroduction of CTF and CGC
Introduction of CTF and CGCKir Chou
 
PyCon TW 2017 - Why do projects fail? Let's talk about the story of Sinon.PY
PyCon TW 2017 - Why do projects fail? Let's talk about the story of Sinon.PYPyCon TW 2017 - Why do projects fail? Let's talk about the story of Sinon.PY
PyCon TW 2017 - Why do projects fail? Let's talk about the story of Sinon.PYKir Chou
 
Ch9 package & port(2013 ncu-nos_nm)
Ch9 package & port(2013 ncu-nos_nm)Ch9 package & port(2013 ncu-nos_nm)
Ch9 package & port(2013 ncu-nos_nm)Kir Chou
 
Ch10 firewall(2013 ncu-nos_nm)
Ch10 firewall(2013 ncu-nos_nm)Ch10 firewall(2013 ncu-nos_nm)
Ch10 firewall(2013 ncu-nos_nm)Kir Chou
 
Knowledge Management in Distributed Agile Software Development
Knowledge Management in Distributed Agile Software DevelopmentKnowledge Management in Distributed Agile Software Development
Knowledge Management in Distributed Agile Software DevelopmentKir Chou
 
Sitcon2014 community by server (kir)
Sitcon2014   community by server (kir)Sitcon2014   community by server (kir)
Sitcon2014 community by server (kir)Kir Chou
 
Ch6 ssh(2013 ncu-nos_nm)
Ch6   ssh(2013 ncu-nos_nm)Ch6   ssh(2013 ncu-nos_nm)
Ch6 ssh(2013 ncu-nos_nm)Kir Chou
 
Ch5 network basic(2013 ncu-nos_nm)
Ch5   network basic(2013 ncu-nos_nm)Ch5   network basic(2013 ncu-nos_nm)
Ch5 network basic(2013 ncu-nos_nm)Kir Chou
 
Ch4 vi editor(2013 ncu-nos_nm)
Ch4    vi editor(2013 ncu-nos_nm)Ch4    vi editor(2013 ncu-nos_nm)
Ch4 vi editor(2013 ncu-nos_nm)Kir Chou
 

More from Kir Chou (17)

Learn from LL(1) to PEG parser the hard way
Learn from LL(1) to PEG parser the hard wayLearn from LL(1) to PEG parser the hard way
Learn from LL(1) to PEG parser the hard way
 
Time travel: Let’s learn from the history of Python packaging!
Time travel: Let’s learn from the history of Python packaging!Time travel: Let’s learn from the history of Python packaging!
Time travel: Let’s learn from the history of Python packaging!
 
Python パッケージの影響を歴史から理解してみよう!
Python パッケージの影響を歴史から理解してみよう!Python パッケージの影響を歴史から理解してみよう!
Python パッケージの影響を歴史から理解してみよう!
 
The str/bytes nightmare before python2 EOL
The str/bytes nightmare before python2 EOLThe str/bytes nightmare before python2 EOL
The str/bytes nightmare before python2 EOL
 
PyCon TW 2018 - A Python Engineer Under Giant Umbrella (巨大保護傘下的 Python 碼農辛酸史)
PyCon TW 2018 - A Python Engineer Under Giant Umbrella (巨大保護傘下的 Python 碼農辛酸史) PyCon TW 2018 - A Python Engineer Under Giant Umbrella (巨大保護傘下的 Python 碼農辛酸史)
PyCon TW 2018 - A Python Engineer Under Giant Umbrella (巨大保護傘下的 Python 碼農辛酸史)
 
Introduction of CTF and CGC
Introduction of CTF and CGCIntroduction of CTF and CGC
Introduction of CTF and CGC
 
PyCon TW 2017 - Why do projects fail? Let's talk about the story of Sinon.PY
PyCon TW 2017 - Why do projects fail? Let's talk about the story of Sinon.PYPyCon TW 2017 - Why do projects fail? Let's talk about the story of Sinon.PY
PyCon TW 2017 - Why do projects fail? Let's talk about the story of Sinon.PY
 
GCC
GCCGCC
GCC
 
Ch9 package & port(2013 ncu-nos_nm)
Ch9 package & port(2013 ncu-nos_nm)Ch9 package & port(2013 ncu-nos_nm)
Ch9 package & port(2013 ncu-nos_nm)
 
Ch10 firewall(2013 ncu-nos_nm)
Ch10 firewall(2013 ncu-nos_nm)Ch10 firewall(2013 ncu-nos_nm)
Ch10 firewall(2013 ncu-nos_nm)
 
Knowledge Management in Distributed Agile Software Development
Knowledge Management in Distributed Agile Software DevelopmentKnowledge Management in Distributed Agile Software Development
Knowledge Management in Distributed Agile Software Development
 
Cms part2
Cms part2Cms part2
Cms part2
 
Cms part1
Cms part1Cms part1
Cms part1
 
Sitcon2014 community by server (kir)
Sitcon2014   community by server (kir)Sitcon2014   community by server (kir)
Sitcon2014 community by server (kir)
 
Ch6 ssh(2013 ncu-nos_nm)
Ch6   ssh(2013 ncu-nos_nm)Ch6   ssh(2013 ncu-nos_nm)
Ch6 ssh(2013 ncu-nos_nm)
 
Ch5 network basic(2013 ncu-nos_nm)
Ch5   network basic(2013 ncu-nos_nm)Ch5   network basic(2013 ncu-nos_nm)
Ch5 network basic(2013 ncu-nos_nm)
 
Ch4 vi editor(2013 ncu-nos_nm)
Ch4    vi editor(2013 ncu-nos_nm)Ch4    vi editor(2013 ncu-nos_nm)
Ch4 vi editor(2013 ncu-nos_nm)
 

Ch7 user management(2013 ncu-nos_nm)