How to generate random numbers by shell
This article mainly introduces shell how to generate random numbers, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to understand.
One: RANDOM
Echo $RANDOM
The random number of RANDOM has a range of 1Murray 32767, which can be cracked generally.
1.2 generate an eight-digit random password:
Echo $(($RANDOM+11111111))
Second: the password generated by MD5sum random encryption method is long.
Take a 9-digit password:
Echo $RADDOM | md5sum | cut-c 2-9
Three: generate random numbers through openssl
[root@web01 tmp] # openssl rand-base64 8
HInfIvtfOSk=
[root@web01 tmp] # openssl rand-base64 10
T67TCWO4DquFjAfee =
[root@web01 tmp] #
Four: get random numbers through time
Date +% s% N (s seconds N)
[root@web01 tmp] # date +% s% N
1494493822328919977
[root@web01 tmp] #
Five: mkpasswd
To use mkpasswd, first download expect
Yum install expect-y
[root@web01 scripts] # mkpasswd-l 10
\ dhr (V56zpT
[root@web01 scripts] # mkpasswd-l 18
UxtxtiLuk09wzDd [ga
[root@web01 scripts] #
6: device: / dev/urandom | cksum
[root@web01 scripts] # head / dev/urandom | cksum
3839730751 3262
[root@web01 scripts] #
Seven: the full name of the uid code is the only universal identification code:
[root@web01 scripts] # cat / proc/sys/kernel/random/uuid
Dbe7d254-11c2-42cc-b541-3f2a990daa8e
[root@web01 scripts] #
Thank you for reading this article carefully. I hope the article "how to generate random numbers in shell" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!