Linux passwd command
The Linux passwd command is used to change a user's password
Syntax
passwd [-k] [-l] [-u [-f]] [-d] [-S] [username]
Required Parameters:
- -d Delete a password
- -f Force the user to change the password at the next login
- -w The number of days before password expiry to warn in advance
- -k Updates can only be sent after expiry
- -l Lock an account
- -S Display password information
- -u Unlock an account that has been locked
- -x Specify the maximum number of days a password remains valid
- -g Modify a group password
- Specify the minimum number of days a password remains valid
- -i The number of days after password expiry before the account is disabled
Select parameters:
- --help display help information
- --version display version information
Example
Change a user's password
# passwd runoob //set the password for the runoob user
Enter new UNIX password: //输入新密码,输入的密码无回显
Retype new UNIX password: //确认密码
passwd: password updated successfully
#
Display account password information
# passwd -S runoob
runoob P 05/13/2010 0 99999 7 -1
Delete a user's password
# passwd -d lx138
passwd: password expiry information changed.
Linux Command Reference