passwd
權限與擁有者
用法
passwd [user]修改登入密碼並把雜湊寫進 /etc/shadow;macOS 幾乎沒有 Linux 那些選項,改用 dscl 或系統設定。
常用選項
| 選項 | 含義 |
|---|---|
| -S | Linux: show the status of the account |
| -l | Linux: lock the account so the password cannot be used |
| -u | Linux: unlock it again |
| -e | Linux: expire the password so it must change at next login |
| -d | Linux: delete the password outright, which is dangerous |
範例
passwdChanges your own password; it asks for the old one first.
sudo passwd deploySets another user password without knowing the old one.
sudo passwd -l olduserLocks the account.
數字模式和符號模式說的是同一件事:755 和 u=rwx,go=rx 是同一個權限。
怎麼看
- 方括號 [ ] 表示這部分可以不寫。
- 省略號 … 表示可以寫多個。
- 選項區分大小寫——有些命令裡 -r 和 -R 不是一回事。
常見問題
Q. passwd 是做什麼的?
修改登入密碼並把雜湊寫進 /etc/shadow;macOS 幾乎沒有 Linux 那些選項,改用 dscl 或系統設定。
Q. 怎麼寫?
passwd [user] —— 方括號表示可以省略的部分。
Q. 值得記的選項有幾個?
這裡列了 5 個,完整列表在 man passwd。這條命令屬於權限與擁有者。
相關命令
man 手冊: man passwd