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 stat Command: Display Detailed File Metadata

Linux stat Command: Display Detailed File Metadata

Learn how to use the Linux stat command to inspect file size, permissions, ownership, timestamps, inode, and filesystem metadata, with essential options, practical examples, output interpretation, and common troubleshooting tips.

Linux Tutorial / Search and Process Text with grep, sort, uniq, cut, and wc

Linux Tutorial / Search and Process Text with grep, sort, uniq, cut, and wc

Practice searching, sorting, grouping, extracting, and counting text with grep, sort, uniq, cut, and wc, including reproducible output and key caveats.

Linux apt-get Command: Run APT Package Operations in Scripts

Linux apt-get Command: Run APT Package Operations in Scripts

Learn how to run APT Package Operations in Scripts with the Linux apt-get command, including practical examples, key options, and important precautions.

How to Check IP Addresses on Linux

How to Check IP Addresses on Linux

Learn how to check private and public IP addresses on Linux, identify the active interface and route, and distinguish IPv4, IPv6, and externally visible addresses.

Linux ip Command: Inspect and Configure Network Interfaces and Routes

Linux ip Command: Inspect and Configure Network Interfaces and Routes

Learn how to inspect and Configure Network Interfaces and Routes with the Linux ip command, including practical examples, key options, and important precautions.

Linux zip Command: Create ZIP Archives

Linux zip Command: Create ZIP Archives

Learn how to create ZIP Archives with the Linux zip command, including practical examples, key options, and important precautions.

Linux Tutorial / Compare Files with diff and cmp

Linux Tutorial / Compare Files with diff and cmp

Use diff and cmp to compare two files, read unified diff output, and distinguish a detected difference from an actual command error.

Linux nslookup Command: Query DNS Names and Records

Linux nslookup Command: Query DNS Names and Records

Learn how to query DNS Names and Records with the Linux nslookup command, including practical examples, key options, and important precautions.

Linux pwd Command: Print the Current Working Directory

Linux pwd Command: Print the Current Working Directory

Learn how to use the Linux pwd command to print the logical or physical absolute path of the current working directory, 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.