Linux generates random password methods:
Strings/dev/urandom | Grep-o ' [[: Alnum:]] ' | Head-n 30 | Tr-d ' n '; Echo
Linux Modify Password Method:
passwd Root
Then enter the new password two times
Root can be replaced by the user who needs to be modified
We have other options besides the random cipher generated above.
1. Using the MKPASSWD command:
Using the MKPASSWD command, you need to install the expect module in advance, taking CentOS as an example:
Yum-y Install expect
After installation, directly run MKPASSWD, you can generate a random password. And the command also has parameters, such as setting the minimum length of the generated random password, and so on, to see Help.
2. Using the Passwdgen command:
In line with the MKPASSWD, the Passwdgen module must be installed beforehand:
Yum-y Install Passwdgen
After installation, directly run Passwdgen, you can get a random password, the same Passwdgen command also has parameters, you can refer to help.
Add some generate random password command
Here are 10 instances of generating random passwords
1.sha+date+base64, Password length 32
Date +%s | Sha256sum | Base64 | Head-c 32; Echo
2. Use Urandom, filter out other symbols, leaving only letters and numbers, password length 32
</dev/urandom TR-DC _a-z-a-z-0-9 | Head-c${1:-32};echo;
3. Random functions using OpenSSL
OpenSSL Rand-base64 32
Another use of 4.urandom, URANDOM+TR
TR-CD ' [: alnum:] ' </dev/urandom | fold-w30 | Head-n1
5. Use Urandom plus character function
Strings/dev/urandom | Grep-o ': alnum: ' | Head-n 30 | Tr-d ' n '; Echo
The simplest use of 6.urandom
</dev/urandom TR-DC _a-z-a-z-0-9 | Head-c6
Another use of 7.urandom, URANDOM+DD
DD if=/dev/urandom Bs=1 count=32 2>/dev/null | Base64-w 0 | Rev | Cut-b 2-| Rev
8. If you often use a single hand to enter a password, you can refer to the following methods to generate "left-handed password"
/dev/urandom tr-dc ' 12345!@#$%QWERTQWERTASDFGASDFGZXCVBZXCVB ' | Head-c8; echo ""
9. Use RANDPW plus urandom
RANDPW () {</dev/urandom tr-dc _a-z-a-z-0-9 | Head-c${1:-16};echo;}
10. Finally, the most concise
Date | Md5sum