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:
Section titled “passwd Syntax:”passwd [options] [username]
passwd Options:
Section titled “passwd Options:”Option | Description |
---|---|
-a, —all | Report password status on all accounts |
-d, —delete | Delete the password for the specified account |
-e, —expire | Force the specified account’s password to expire |
-h, —help | Display help message |
-l, —lock | Lock the password of the specified account |
-u, —unlock | Unlock the password of the specified account |
Parameters:
Section titled “Parameters:”Parameter | Description |
---|---|
username | The username for which the password should be changed |
passwd Command Usage Examples:
Section titled “passwd Command Usage Examples:”Change password for the current user
Section titled “Change password for the current user”passwd
Allows the current user to change their password.
Change password for a specific user
Section titled “Change password for a specific user”sudo passwd username
Enables an authorized user to change the password for a specified username.
Force password change on the next login
Section titled “Force password change on the next login”sudo passwd -e username
Forces the specified user to change their password upon the next login.
Lock a user account
Section titled “Lock a user account”sudo passwd -l username
Locks the specified user account, preventing login until the password is reset.
Unlock a user account
Section titled “Unlock a user account”sudo passwd -u username
Unlocks the specified user account, allowing login with the current password.
How do I change my own password in Linux?
Section titled “How do I change my own password in Linux?”To change your own password using the passwd command in bash, execute the following command:
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:
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:
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:
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:
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:
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:
sudo passwd --maxdays <days> --mindays <days> --warndays <days> --inactivedays <days> <username>
Applications of the passwd command
Section titled “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