方法1 tr + head
[root@zfw ~]# tr -cd 'a-zA-Z0-9' </dev/urandom |head -c8
方法2 date
[root@zfw ~]# date +%N
date +%N |md5sum |head -c10
[root@zfw ~]# date +%N|md5sum |head -c8
方法3 RANDOM环境变量
RANDOM生成随机数字
echo $RANDOM
RANDOM + md5sum
RANDOM +数字
[root@zfw ~]# echo $((RANDOM+10000000))
方法4 uuidgen
[root@zfw ~]# uuidgen
[root@zfw~]# uuidgen|cut -b 1-8
方法5 mkpasswd
mkpasswd|cut -b 1-8 (需要单独安装)
方法6 openssl
openssl rand -base64 8
[root@zfw ~]# openssl rand -base64 8|cut -c 1-8
方法7 string 字符转换 转换为人类可读
strings /dev/urandom | tr -cd 'a-zA-Z0-9' |head -c8
方法8 gpg
[root@zfw ~]# gpg --gen-random -armor 1 12