Skip to content

What is passwd Linux command?

The Linux passwd command is used to change a user’s password. It allows users to update their passwords securely and manage their account access.

Terminal window
passwd [options] [username]
OptionDescription
-a, —allReport password status on all accounts
-d, —deleteDelete the password for the specified account
-e, —expireForce the specified account’s password to expire
-h, —helpDisplay help message
-l, —lockLock the password of the specified account
-u, —unlockUnlock the password of the specified account
ParameterDescription
usernameThe username for which the password should be changed
Terminal window
passwd

Allows the current user to change their password.

Terminal window
sudo passwd username

Enables an authorized user to change the password for a specified username.

Terminal window
sudo passwd -e username

Forces the specified user to change their password upon the next login.

Terminal window
sudo passwd -l username

Locks the specified user account, preventing login until the password is reset.

Terminal window
sudo passwd -u username

Unlocks the specified user account, allowing login with the current password.

To change your own password using the passwd command in bash, execute the following command:

Terminal window
passwd

How do I change another user’s password in Linux?

Section titled “How do I change another user’s password in Linux?”

To change another user’s password using the passwd command in bash, execute the following command as a superuser:

Terminal window
sudo passwd <username>

How do I force a user to change their password on next login in Linux?

Section titled “How do I force a user to change their password on next login in Linux?”

To force a user to change their password on the next login using the passwd command in bash, execute the following command as a superuser:

Terminal window
sudo passwd --expire <username>

How do I lock a user account in Linux using passwd?

Section titled “How do I lock a user account in Linux using passwd?”

To lock a user account using the passwd command in bash, execute the following command as a superuser:

Terminal window
sudo passwd --lock <username>

How do I unlock a user account in Linux using passwd?

Section titled “How do I unlock a user account in Linux using passwd?”

To unlock a user account using the passwd command in bash, execute the following command as a superuser:

Terminal window
sudo passwd --unlock <username>

How do I display password status information in Linux using passwd?

Section titled “How do I display password status information in Linux using passwd?”

To display password status information using the passwd command in bash, execute the following command as a superuser:

Terminal window
sudo passwd --status <username>

How do I set password aging or expiration policies in Linux using passwd?

Section titled “How do I set password aging or expiration policies in Linux using passwd?”

To set password aging or expiration policies using the passwd command in bash, execute the following command as a superuser:

Terminal window
sudo passwd --maxdays <days> --mindays <days> --warndays <days> --inactivedays <days> <username>
  • Change a user’s password
  • Update user’s password aging information
  • Lock or unlock a user’s password
  • Verify the current user’s password