|
指定密码:
#!/bin/bash ULIST=$(cat /root/users.txt) ##/root/users.txt 里面存放的是用户名,一个名一行 for UNAME in $ULIST do useradd $UNAME echo "123456" | passwd --stdin $UNAME
done
----------
#!/bin/bash PREFIX="stu" i=1 while [ $i -le 20 ] do useradd ${PREFIX}$i echo "123456" | passwd --stdin ${PREFIX}$i &> /dev/null let i++
done
--------------------------------------------------------- 随机密码,不保存:
#!/bin/bash for user in test{01..10} do useradd $user echo `date +%s%N`|md5sum |egrep '.{8}' -o|passwd --stdin $user
done
----------
#!/bin/bash i=1 while [ $i -le 10 ] do useradd -r test$i echo `date +%s%N`|md5sum |egrep '.{8}' -o|passwd --stdin test$i let i++
done
--------------------------------------------------------- 随机密码,并保存:
#!/bin/bash for u in la{01..10} do useradd $u &>/dev/null if [ $? -eq 0 ] then echo "add user is ok" p=`uuidgen` echo $p|passwd --stdin $u &>/dev/null echo "$u:$p" >>/tmp/userlist else echo "add user is error" fi
done
----------
#!/bin/bash source /etc/init.d/functions
for i in biu{01..10} do useradd $i &>/dev/null if [ $? -eq 0 ] then action "$i" /bin/true pass=`uuidgen` echo $pass|passwd --stdin $i &>/dev/null echo "$i:$pass" >>/tmp/uuulist else action "$i" /bin/false fi done
|