9.7 User Management (7): Set or modify user passwords
Use the passwd command to set or modify the user's password, both ordinary and super-privileged users can run passwd, ordinary users can only change their own user password, the root user can set or modify any user's password.
If the passwd command is not followed by any option or user name, the current user's password is modified.
Command syntax:
passwd [Options] [user name]
The meanings of the options in the command are as shown in the table.
Options |
option meaning |
-D |
Delete user password, can only be operated as root user |
-L |
Lock the password of the user account |
-U |
Unlock password for user account |
-E |
Terminate the password for the named account |
-X < days > |
Maximum effective time limit for passwords |
-N < days > |
Minimum effective time limit for passwords |
-W < days > |
Start reminding users how many days before the password expires |
-I < days > |
How many days after the password expires the account will be disabled |
-S |
Querying the user's password status |
Example: Set the user's it password.
[Email protected] ~]# useradd it [[email protected] ~]# passwd It changes user it's password. New Password://Enter the user's it password to reenter the new password://Enter the user it password passwd: All authentication tokens have been successfully updated.
Example: Lock the user's it password.
[[email protected] ~]# passwd-l It locks the password of the user it. PASSWD: Successful operation
Example: Unlocking the user's it password.
[[email protected] ~]# Passwd-u It unlocks the password of the user it. PASSWD: Successful operation
this excerpt from linux learning linux introductory textbook. To read the entire book, please visit OPS ( www.linuxywz.com
"Linux learning is not difficult" user management (7): Set or modify user password