Linux passwd Command: Change a User Password

passwd is a command that interactively changes your account password. If you have administrator privileges, you can also change the passwords of other accounts, but you must verify the target account.

What is the passwd command?

Normal users usually enter their current password followed by the new password in sequence. It is normal if characters are not displayed on the screen during input. Actual validation policies and storage locations are influenced by PAM settings and the distribution's policies.

Basic syntax

passwd [option] [user]

Installed implementations and options may vary depending on the distribution. Check the current system's description with man passwd.

Examples

Changing your own password

Follow the interactive prompts to enter your current password and new password.

passwd

Changing another account's password

The administrator executes it after accurately confirming the target username.

sudo passwd alice

Check Password Status

Summarize the password status and expiration information of an account with administrative privileges.

sudo passwd -S alice

Interactive Change Process and Verification

General users usually change their account passwords with passwd. When executing the command, prompts asking for the current password and the new password may appear in order.

passwd

Example screen (phrases may vary depending on the distribution and account policy):

Current password:
New password:
Retype new password:
passwd: password updated successfully

It can be normal if letters or asterisks do not appear on the terminal when entering the password. Do not put the actual password in command arguments or documentation examples. Changing another user's password with an administrator account affects account policies and audit records, so double-check the target name and perform the task only with the necessary permissions.

Main Options and Format

Options/Format Description
-S Summarize the password status of the account.
-l Lock password authentication. This does not block all other login methods.
-u Unlock the locked password authentication.
-e Expire the password to require a change at the next login.

Precautions when using

Do not write the password directly in the command arguments. It can be exposed in shell history or process lists. passwd -l locks password-based authentication but does not necessarily block other authentication methods like SSH keys. To completely deactivate an account, the service and authentication policies should be checked as well.

Frequently Asked Questions

Even if nothing appears when entering the password, is it being entered?

Yes. For security reasons, it is common that the characters you type are not displayed and are replaced with asterisks. Press Enter after completing your input.

Official Documentation

You can check the exact behavior of the options and the differences in implementation in the official passwd documentation.

More in This Category
Linux ping Command: Test Host Reachability and Round-Trip Time

Linux ping Command: Test Host Reachability and Round-Trip Time

Learn how to test Host Reachability and Round-Trip Time with the Linux ping command, including practical examples, key options, and important precautions.

Linux tree Command: Display a Directory Tree

Linux tree Command: Display a Directory Tree

Learn how to use the Linux tree command to display directory contents as a readable hierarchy and control depth and filtering, with essential options, practical examples, output interpretation, and common troubleshooting tips.

Linux unxz Command: Decompress xz Files

Linux unxz Command: Decompress xz Files

Learn how to decompress xz Files with the Linux unxz command, including practical examples, key options, and important precautions.

Linux shred Command: Overwrite File Data and Understand Its Limits

Linux shred Command: Overwrite File Data and Understand Its Limits

Learn how Linux shred overwrites file data, which options control its passes and removal, and why SSDs, snapshots, backups, and modern filesystems limit its guarantees.

Linux type Command: Identify How a Command Is Resolved

Linux type Command: Identify How a Command Is Resolved

Learn how to use the Linux type command to identify aliases, functions, built-ins, keywords, and executable paths, with essential options, practical examples, output interpretation, and common troubleshooting tips.

Linux sort Command: Sort Text Lines

Linux sort Command: Sort Text Lines

Learn how to sort text lines with the Linux sort command, including practical examples, key options, and important precautions.

Linux groups Command: Show a User's Group Memberships

Linux groups Command: Show a User's Group Memberships

Learn how to show a User's Group Memberships with the Linux groups command, including practical examples, key options, and important precautions.

Linux timedatectl Command: Check Time Zone and Time Synchronization

Linux timedatectl Command: Check Time Zone and Time Synchronization

Learn how to check Time Zone and Time Synchronization with the Linux timedatectl command, including practical examples, key options, and important precautions.

Linux nohup Command: Keep a Command Running After Logout

Linux nohup Command: Keep a Command Running After Logout

Learn how to use the Linux nohup command to keep a command running after the terminal closes or the user logs out, with essential options, practical examples, output interpretation, and common troubleshooting tips.

Linux fdisk Command: Inspect and Edit Disk Partitions

Linux fdisk Command: Inspect and Edit Disk Partitions

Learn how to inspect and Edit Disk Partitions with the Linux fdisk command, including practical examples, key options, and important precautions.