##deleate
rm -f /root/user_password.txt /root/user_names.txt /root/user_list.txt
##create stu01-stu10
echo stu{01..10}|xargs -n1 >> /root/user_names.txt
##create users stu01-stu10 and build password
cat /root/user_names.txt|sed ‘s#.*#useradd &;echo $RANDOM |md5sum|cut -c 1-8 >>/root/user_password.txt;tail -1 /root/user_password.txt |passwd --stdin &#g‘|bash
###log name and password
cat /root/user_names.txt |xargs -n10 >/root/user_list.txt && cat /root/user_password.txt |xargs -n10 >>/root/user_list.txt
###show the list
cat /root/user_list.txt
纯linux命令批量创建用户并设置随机密码且显示用户和密码的脚本
原文地址:http://11361008.blog.51cto.com/11351008/1914692