Permissions, users and access

Command passwd

Change user password

Linux · Bash examples · commands run on the selected server

When to use passwd

Use passwd to change passwords through the system's authentication policy. Password prompts are interactive and should never be replaced by placing a real password directly in a command line or saved snippet.

Syntax

passwd [OPTIONS] [USER]

Square brackets mark optional arguments; an ellipsis means repetition. Replace example file names, user names and server addresses with your own values.

Common options and arguments

-S
Show password status in Linux shadow-utils.
-l
Lock account password.
-u
Unlock account password.

Usage examples

Change your password

passwd

The current account changes its password after the required identity checks.

Show password status

passwd -S

Account password status is displayed rather than the password itself.

Change the selected user's password

sudo passwd deploy

An authorised administrator changes the named account's password; coordinate this to avoid locking out its owner.

Notes and limitations

  • The new password is entered interactively; don't pass it on the command line.
  • Password locking does not necessarily prevent login using the SSH key or other authentication methods.

Common questions and troubleshooting

Why are no characters visible while typing?

Password prompts normally suppress echo, including placeholder stars. Enter the password carefully and follow the confirmation prompt.

Why is a chosen password rejected?

Local or centrally managed policy may enforce complexity, age or history requirements. Follow that policy instead of disabling it to complete a test.

Further help

Options vary by version and distribution. Check the installed documentation with this command: man passwd.