passwd(1)
Change user password or password-related information.
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
| Flag | What it does |
|---|---|
-d | Delete the password (make the account passwordless) |
-e | Force user to change password on next login |
-l | Lock the user account by disabling login |
-u | Unlock the user account |
-x DAYS | Set maximum password validity in days |
-n DAYS | Set minimum number of days before password can be changed |
-w DAYS | Set number of days warning before password expiration |
-i DAYS | Set number of days after expiration before account lockout |
-S | Display password status information |
Examples
Change your own password; prompts for old password, then new password twice
passwdChange john's password as root (skips old password verification)
sudo passwd johnLock user1's account, preventing login
passwd -l user1Unlock user1's account after it was locked
passwd -u user1Expire user2's password, forcing change on next login
passwd -e user2Display password status for alice (lock status, last change, etc.)
passwd -S aliceSet bob's password to expire after 90 days of non-use
sudo passwd -x 90 bob