Processing in passwd command
- Verify current user password : Once the user enters passwd command, it prompts for current user password, which is verified against the password stored in /etc/shadow file user. The root user can bypass this step and can directly change the password, so as the forgotten passwords may be recovered.
- Verify password aging information : In Linux, a user password can be set to expire after a given period of time. Also, a user can be prohibited to change his/her password for a period. This password aging information (and the password itself) is stored in a file /etc/shadow.
- Change the password : After authentication, the user is prompted to enter the new password and verify it by retyping the password.
- /etc/shadow file: The shadow file is a list of colon separated values with 9 fields, as shown below:
user1:$6$x8wAJRpP$EWC97sXW5tqac10Q2TQyXkR.1l1jdK4VLK1pkZKmA2mbA6UnSGyo94Pis074viWBA3sVbkCptSZzuP2K.y.an/:17887:0:99999:7:::
- field 1: User name.
- field 2: Encrypted Password.
- field 3: Number of days since January 1, 1970 to when the password was last changed.
- field 4: Minimum number of days for which password can not be changed. (value 0 means it can be changed anytime).
- field 5: Number of days after password must be changed. (value 99999 means that the password never expires).
- field 6: Number of days to warn user for expiring password.
- field 7: Number of days after password expires that the account is disabled.
- field 8: The number of days from January 1, 1970 to the date when an account was disabled.
- field 9: This field is reserved for some possible future use.
How to Change User Password in Linux | passwd Command
Securing user accounts is a fundamental aspect of maintaining a robust and secure Linux system. One essential task is changing user passwords regularly to prevent unauthorized access. The passwd
command in Linux provides a straightforward and effective way to modify user passwords. This article will guide you through the process of changing user passwords using the passwd
command, offering insights into its various options and best practices.
Table of Content
- Understanding the `passwd` Command
- Basic Syntax of `passwd` in Linux
- Options Available in `passwd` Command in Linux
- 1. How to Change User Password in Linux
- 2. How to Change Another User’s Password in Linux
- 3. How to Change the User Password Forcely
- 4. How to Lock and Unlock User Account in Linux
- 5. How to Set Password Expiry
- Processing in passwd command: