passwd command

The passwd command allows a user to change their password or to allow a superuser to change another user’s password.

Command: passwd
Synopsis: passwd [option] [user]

Options:
Below is a list of the options that can be used with the passwd command. You can stack them, using more than one at a time.

OptionLong NameDescription
-kThe option -k is used to indicate that the update should only be for expired passwords.
-lThis option is used to lock the specified account. The command is only available for root users. The locking is performed by rendering the encrypted password into an invalid string (by prefixing the encrypted string with an !).
-uThis is the reverse of the -l (lock) option. It will unlock the account password by removing the ! prefix. This option is available to root only. Using the force option -f will override this protection.
-dThis is a quick way to delete a password for an account. It will set the named account passwordless. Available to root only.
-nThis will set the minimum password lifetime, in days, if the userâs account supports password lifetimes. Available to root only.
-xThis will set the maximum password lifetime, in days, if the userâs account supports password lifetimes. Available to root only.
-wThis will set the number of days in advance the user will begin receiving warnings that her password will expire, if the userâs account supports password lifetimes. Available to root only.
-iThis will set the number of days which will pass before an expired password for this account will be taken to mean that the account is inactive and should be disabled, if the userâs account supports password lifetimes. Available to root only.
-SThis will output a short information about the status of the password for a given account. Available to root user only.

Examples:

passwd test1
Changing password for user test1.
New UNIX password:
Retype new UNIX password:
passwd: all authentication tokens updated successfully.

passwd -l test1
passwd -l test1
Locking password for user test1.
passwd: Success

Was this article helpful? Join the conversation!