The passwd command is used to change the password for the current user or for another user. The syntax for the passwd command is:
Bash
passwd [options] usernameThe username parameter is the name of the user whose password you want to change. If the username parameter is not specified, the password for the current user will be changed.
The following table lists the parameters for the passwd command:
| Parameter | Description |
|---|---|
-l | Lock the user account. |
-u | Unlock the user account. |
-d | Delete the user account. |
-S | Change the shadow password. |
Here are some examples of how to use the passwd command:
Bash
# Change the password for the current user
passwd
# Change the password for the user named 'johndoe'
passwd johndoe
# Lock the user account named 'johndoe'
passwd -l johndoe
# Unlock the user account named 'johndoe'
passwd -u johndoe
# Delete the user account named 'johndoe'
passwd -d johndoe
# Change the shadow password for the current user
passwd -SThe passwd command is a powerful tool that should be used with caution. It is important to make sure that you are changing the password for the correct user.
Here are some additional notes about the passwd command:
- The
passwdcommand requires the current user’s password to change the password for another user. - The
passwdcommand does not require the root user password to change the password for the root user. - The
passwdcommand will not change the password if the new password is the same as the old password.
