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.

passwd Syntax:

Terminal window
passwd [options] [username]

passwd Options:

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

Parameters:

ParameterDescription
usernameThe username for which the password should be changed

passwd Command Usage Examples:

Change password for the current user

Terminal window
passwd

Allows the current user to change their password.

Change password for a specific user

Terminal window
sudo passwd username

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

Force password change on the next login

Terminal window
sudo passwd -e username

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

Lock a user account

Terminal window
sudo passwd -l username

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

Unlock a user account

Terminal window
sudo passwd -u username

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

How do I change my own password in Linux?

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?

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?

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?

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?

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?

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?

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>

Applications of the passwd command

  • Change a user’s password
  • Update user’s password aging information
  • Lock or unlock a user’s password
  • Verify the current user’s password