linux产生随机的方法
取8位数字的方法
1
2
|
[root@master scripts]
# echo $RANDOM
12465
|
1
2
|
[root@master scripts]
# echo $((RANDOM+10000000))
10023190
|
1
2
|
[root@master scripts]
# echo $RANDOM | md5sum | cut -c 1-8
ae74cedb
|
1
2
|
[root@master scripts]
# uuidgen| md5sum | cut -c 1-8
fdfca8ec
|
1
2
|
[root@master scripts]
# mkpasswd -l 8
6zhFj7T>
|
1
2
|
[root@master scripts]
# echo `date +%s` | md5sum | cut -c 1-8
f6d58a59
|
更随机的方法
1
2
|
[root@master scripts]
# echo "`date +%s`$RANDOM" | md5sum | cut -c 1-8
0daddd89
|
1
2
|
[root@master scripts]
# openssl rand -base64 4
jW
/xRw
==
|
1
2
|
[root@master scripts]
# head /dev/urandom | cksum
1181625912 2520
|
1
2
|
[root@master scripts]
# cat /proc/sys/kernel/random/uuid == uuidgen
dfdec661-b0b7-48d3-b0db-73d1d7d09e06
|
cuizhiliang