#批量创建大量用户
#! /bin/bash
#思路
#useradd zhangsan
#echo 1234 |passwd --stdin zhangsan
#截取随机数的8个字符作为密码
#echo $RANDOM |md5sum |cut -c 1-8
#echo {1..10},有序打印1~10的数字
#id zhangsan 判断是否有该用户
#完整,循环语句创建
USER_FILE=./user.info
for USER in user{1..10}:do
if ! $USER &>/dev/null;then
PASS=$(echo $RANDOM |md5sum |cut -c 1-8)
useradd $USER
echo $PASS|passwd --stdin $USER
echo "$USER $PASS" >>$USER_FILE
else
echo "$USER User already exists!"
fi
done
标签:10,用户名,运维,创建,echo,----,USER,PASS,zhangsan From: https://www.cnblogs.com/ciscolee/p/16603200.html