Scripts to create 10 system account, and set a password (the password is a random number, requires mixing characters and numbers, etc.)

#!/bin/bash
for i in `seq 1 10`
do
if id user-$i > /dev/null; then
read -eq "user-$i用户已存在, 是否删除(y/n)" ss
if [ $ss = y ]:then
userdel -rf user-$i
elif [ $ss = n ];then
continue
else
"输入有误"
fi
else
useradd user-$1
if [ $? -eq 0 ];then
echo "user-$i 创建成功"
passwd="user`cat /dev/urandom | head -1 | md5sum | head -c 5 `"
echo "user-$i:$passwd" chpasswd
echo "user-$i--$passwd" >> user.txt
else
echo "user-$i 创建失败"
fi
fi
done

Guess you like

Origin www.cnblogs.com/sqht/p/11598176.html