批量创建账号脚本
密码通过uuid随机生成八位, 用户名 seq -w 10 生成 01-10
#!/bin/bash . /etc/init.d/functions USER="oldboy" PASSFILE=/tmp/user.log for num in `seq -w 10`;do PASS=`cat /proc/sys/kernel/random/uuid|awk -F '-' '{print $1}'` useradd $USER$num &>/dev/null echo $PASS | passwd --stdin $USER$num &>/dev/null echo -e "user: $USER$num\tpasswd:$PASS" >>$PASSFILE if [ $? -eq 0 ];then action "$USER$num create success." /bin/true else action "$USER$num create failed." /bin/false fi done
使用 openssl -rand -base64 8 生成的随机密码更好