$linuxjunkies
>

passwd(1)

Change user password or password-related information.

UbuntuDebianFedoraArch

Synopsis

passwd [OPTION] [USER]

Description

The passwd command is used to change user account passwords and manage password expiration policies. When run without arguments, it changes the password of the current user; when run as root, it can change any user's password or lock/unlock accounts.

Passwords are stored in the /etc/shadow file (readable only by root), while user account information is in /etc/passwd. The command prompts for the old password before accepting a new one, unless run with elevated privileges.

Common options

FlagWhat it does
-dDelete the password (make the account passwordless)
-eForce user to change password on next login
-lLock the user account by disabling login
-uUnlock the user account
-x DAYSSet maximum password validity in days
-n DAYSSet minimum number of days before password can be changed
-w DAYSSet number of days warning before password expiration
-i DAYSSet number of days after expiration before account lockout
-SDisplay password status information

Examples

Change your own password; prompts for old password, then new password twice

passwd

Change john's password as root (skips old password verification)

sudo passwd john

Lock user1's account, preventing login

passwd -l user1

Unlock user1's account after it was locked

passwd -u user1

Expire user2's password, forcing change on next login

passwd -e user2

Display password status for alice (lock status, last change, etc.)

passwd -S alice

Set bob's password to expire after 90 days of non-use

sudo passwd -x 90 bob

Related commands