Linux下批量创建用户、密码及用户主目录
2010-04-21 20:47
#Batch to add users in linux system
#Author : zhanglei
#E-mail : ceocreator@126.com
#----------------------------------------------
#newusers < ./userconf/userlist.txt
#pwunconv
#chpasswd < ./userconf/passwdlist.txt
#pwconv
#----------------------------------------------
#!/bin/bash
echo
num=0
username=user
tmpuser=""
userpasswd=""
useradd -m user -p "user123" -s "/bin/bash" # create user and user group
for ((i=1; i<=25; i++)) #1 2 3...25
do
printf -v num "%.3d" $i
userno=$num
tmpuser="$username$userno"
userpasswd="$username-$userno"
useradd -m "$tmpuser" -g user -p "$userpasswd" -s "/bin/bash"
echo "********************************************"
done
阅读(1457) | 评论(1) | 转发(0) |