Change passwords
The passwd command is used to change passwords of Linux users. To change a password of a specific user account, simply type the passwd command, followed by the name of the user whose password you would like to change:
To view information about the password for a specific user account, use the -S option:
Let’s examine the example above. The first field of the output represents the user’s login name (john). The second field indicates if the user account has a locked password (L), has no password (NP), or has a usable password (P). The third field is the date of the last password change. The fourth field is the minimum password age (0 means that the password can be changed at any time), the fifth field is the maximum password age, the sixth field is represent the warning period, and the seventh field is the password inactivity period.
To lock an account, you can use the -l option:
To unlock an account, use the -u option:
To remove a password from an account, use the -d option:
Ordinary users can change only their own password. This can be done by invoking the passwd command without any arguments. The program will ask for the user’s old password as a security measure: