Command Name:
passwd
Description:
Changes the password for the user accounts. Normal user may only change for their own account. Super user can change password for any account.
Syntax:
passwd [options] [username]
Use case:
To set a personal key for a user's PC. To allow only authorized users access to computer system.
Examples:
1. [user@host ~]$ passwd -S Adam
Explanation: Displays current status of the user.
2. [user@host ~]$ passwd -a
Explanation: Displays the status for all users.
3. [user@host ~]$ passwd -d John
Explanation: Deletes the password for the specified user.
4. [user@host ~]$ passwd -l user2
Explanation: Locks the password for the named account.
5. [user@host ~]$ passwd -e Ramirez
Explanation: Immediately expires the password. Forces the user to change their password.
6. [user@host ~]$ passwd -h
Explanation: Displays help message and exit.
7. [user@host ~]$ passwd -i 7 user12
Explanation: Put the amount of days you want to be inactive for (i.e 7).
8. [user@host ~]$ passwd -u user3
Explanation: Unlock the password for the username.
9. [user@host ~]$ passwd -w 20 user7
Explanation: Set the number of days of warning before a password change (ex: 20).
10. [user@host ~]$ passwd -x 15 Lin
Explanation: Set the number of days a password remains valid.
11. [user@host ~]$ passwd:
Changing password for user username.
(current) UNIX password:
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
12. Change Another User's Password (As root or with sudo):
Explanation: Change the password for another user, use the 'passwd' command followed by the username of the user whose
password you want to change.
13. [user@host ~]$ passwd -sudo passwd username
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully