The passwd
command is used to update a user’s password. Users can only change their own passwords, whereas the root user can update the password for any user.
passwd [OPTIONS] [USER]
For example, since we are logged in as the sysadmin user we can change the password for that account. Execute the passwd
command. You will be prompted to enter the existing password once and the new password twice. For security reasons, no output is displayed while the password is being typed. The output is shown as follows:
If the user wants to view status information about their password, they can use the -S
option:
The output fields are explained below:
Field | Meaning | Meaning |
---|---|---|
User Name | sysadmin | The name of the user. |
Password Status | P | P indicates a usable password. L indicates a locked password. NP indicates no password. |
Change Date | 08/05/2021 | The date when the password was last changed. |
Minimum | 0 | The minimum number of days that must pass before the current password can be changed by the user. |
Maximum | 99999 | The maximum number of days remaining for the password to expire. |
Warn | 7 | The number of days prior to password expiry that the user is warned. |
Inactive | -1 | The number of days after password expiry that the user account remains active. |
The root user can change the password of any user. If the root user wants to change the password for sysadmin, they would execute the following command: