Search

How to use passwd command to manage user passwords

The Linux passwd command is a tool used to change and manage a Linux user's password. When executing the Linux passwd command, you will be prompted for entering the password twice.

Option Description
-r Specifies the repository to which an operation is applied.
-a Show password attributes for all entries.
-d Deletes password for name.
-l Locks password entry for name.
-e Change the login shell.
-f Force the user to change password at the next login by expiring the password for name.
-g Change the gecos (finger) information.
-h Change the home directory.
-n min Set minimum field for name. The min field contains the minimum number of days between password changes for name. If min is greater than max, the user may not change the password. Always use this option with the -x option, unless max is set to -1 (aging turned off). In that case, min need not be set.
-s Displays information including your username and if you do/don't have a password
-w warn Set warn field for name. The warn field contains the number of days before the password expires and the user is warned. This option is not valid if password aging is disabled.
-x max Set maximum field for name. The max field contains the number of days that the password is valid for name. The aging for name will be turned off immediately if max is set to -1. If it is set to 0, then the user is forced to change the password at the next login session and aging is turned off.
name Login ID of user

A common Example of using passwd commad is shown below.

[root@localhost ~]# passwd tintin
Changing password for user tintin.
New UNIX password:
Retype new UNIX password:
passwd: all authentication tokens updated successfully.

Related Tutorials
• Introduction to Linux user administration
• How to add a user in Linux using useradd command
• How to modify a Linux user using usermod command
• How to set Linux password aging using chage command
• How to remove user from Linux using userdel command
• The Linux user database (/etc/passwd)
• The Linux password database (/etc/shadow)
• Introduction to Linux User Group
• How to create a new group in Linux using groupadd command
• Linux Group Database (/etc/group) file
• How to manage Linux user group