[root@localhost ~]# cat user.sh #!/bin/bash for i in `seq 1 20` do pw=`echo $[$RANDOM]|md5sum|cut -c 1-4` useradd user$i echo "user$i $pw" >> /root/pw.txt echo "user$pw" |passwd --stdin user$i done
随机密码的另外的方式
[root@localhost ~]# cat /dev/urandom | head -1|md5sum |head -c 5
[root@localhost ~]# cat /dev/urandom | strings -n 5 | head -n 1
[root@shnne ~]# cat userdd.sh #!/bin/sh . /etc/init.d/functions for n in `seq -w 10` do pass=`echo $RANDOM|md5sum|cut -c 1-6` useradd shnne$n && \ echo $pass|passwd --stdin shnne$n >/dev/null 2>&1 action "useradd shnne$n is ok" /bin/true echo -e "shnne$n\t$pass" >> /root/passwd.txt done