passwd Command Examples in Linux

The passwd command is used to either set the user’s initial password or modify the user’s existing password. The syntax of the passwd command is as follows:

$ passwd [username]

The root user can set the password for any user to any value without knowing his current password. As a regular user, simply type the command at the CLI. You’ll see something like this in response:

$ passwd
Changing password for geek.
Old Password:

Once you’ve entered the old password, you’re asked for the new one, and then asked to repeat it. If you enter the same new password twice, it’s changed. It looks like this. Note that the actual passwords you’ve typed do not show up on the screen.

New password:
Re-enter new password:
Password changed.

passwd command examples

1. To lock the user account:

# passwd -l geek

2. To unlock the user account:

# passwd -u geek

3. To delete the password for the user account:

# passwd -d geek

4. To expire the password for the user account:

# passwd -e geek

5. To set the min / max password life

# passwd -n 10 geek
# passwd -x 100 geek

6. To set warning message time:

# passwd -w 2 geek

7. To set the user account inactivity time:

# passwd -i 20 geek

8. To get the short info about user account passwd:

# passwd -S geek
Related Post