#!/bin/sh
i=0
while true
do
let i=i+1
echo "u"$i":123456" >>/root/user.txt
echo "createing user u$i ................."
useradd u$i
if [ $i -eq 100 ]
then
/usr/sbin/chpasswd /root/user.txt
/bin/rm -f /root/user.txt
exit
fi
done
#if you want to delete all of the user,you can
#i=0
#while true
#do
# let i=i+1
# echo "deleteing user u$i ................."
# userdel -r u$i
# if [ $i -eq 100 ]
# then
# exit
# fi
#done
供参考
脚本批量创建用户
mkdir /home/nisuser
vim /useradd.sh
#!/bin/bash
#
for u in {1001..1100}
do
USER=user$u
useradd -d /home/nisuser/$USER -u $u $USER
echo "passwd$u" | passwd --stdin $USER
done
chmod u+x /useradd.sh
./useradd.sh