Updating User Passwords in Linux

Updating User Passwords in Linux

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:

FieldMeaningMeaning
User NamesysadminThe name of the user.
Password StatusPP indicates a usable password.
L indicates a locked password.
NP indicates no password.
Change Date08/05/2021The date when the password was last changed.
Minimum0The minimum number of days that must pass before the current password can be changed by the user.
Maximum99999The maximum number of days remaining for the password to expire.
Warn7The number of days prior to password expiry that the user is warned.
Inactive-1The 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:

Leave a Reply
Your email address will not be published. *

This site uses Akismet to reduce spam. Learn how your comment data is processed.