Home·Terminal commands

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

FlagMeaning
-SLinux: show the status of the account
-lLinux: lock the account so the password cannot be used
-uLinux: unlock it again
-eLinux: expire the password so it must change at next login
-dLinux: delete the password outright, which is dangerous

Examples

passwd

Changes your own password; it asks for the old one first.

sudo passwd deploy

Sets another user password without knowing the old one.

sudo passwd -l olduser

Locks 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