How to use passwd
Passwd (option) (parameter)
Options-
-d: delete the password and only the system administrator can use it
-f: enforcement
-k: the setting can only be updated after the password expires.
-l: lock the password
-s: lists the information about the password, which can only be used by the system administrator
-u: unlock the locked account
A tool for automatically generating passwords: mkpasswd
The default command does not exist to install the package
Yum install-y expect
View mkpasswd parameter settings
Command parameters:
-l # (length definition of password, default is 9)
-d # (number of numbers, default is 2)
-c # (number of lowercase characters, default is 2)
-C # (number of uppercase characters, default is 2)
-s # (number of special characters, default is 1)
-v (details.)
-p prog (program sets password, default is passwd)
Example 1: generate a 12-bit password
Mkpasswd-l 12
Example 2: generate a 12-digit password with 5 digits without a string
Mkpasswd-l 12-d 5-s 0
Example 3: how to set a password for a user in a script
Passwd-stdin lizheng