#!/bin/bash
name="user"
for number in $(seq 1 20)
do
password=$(cat /dev/urandom | head -1 | md5sum| head -c 5)
useradd $name$number
echo "$password" | passwd --stdin $name$number >& /dev/null
echo "$name$number $password" >> userinfo.txt
doneuseradd .sh 批量添加用户
原文:http://blog.51cto.com/innocence/2106760