passwd
Permissions
Usage
passwd [user]Changes a login password and stores its hash in /etc/shadow; macOS has almost none of the Linux flags and uses dscl or System Settings instead.
Common flags
| Flag | Meaning |
|---|---|
| -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 |
Examples
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.
Numeric and symbolic modes name the same thing: 755 and u=rwx,go=rx are the same permission.
How to read this
- Square brackets [ ] mark a part you may leave out.
- An ellipsis … means you can list more than one.
- Flags are case-sensitive — in some commands -r and -R do different things.
Questions
Q. What does passwd do?
Changes a login password and stores its hash in /etc/shadow; macOS has almost none of the Linux flags and uses dscl or System Settings instead.
Q. How do I type it?
passwd [user] — square brackets mark the parts you can leave out.
Q. How many flags are worth knowing?
5 are listed here; the full set is in man passwd. This command sits under Permissions.
Related commands
man page: man passwd