#!/bin/bash
for i in `seq 1 10`
do
if id user-$i > /dev/null;then
read -ep "user-$i用户已存在是否删除(y/n)" aa
if [ $aa = y ];then
userdel -rf user-$i
elif [ $aa = n ];then
continue
else
"输入有误"
fi
else
useradd user-$i
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" >> b.txt
else
echo "user-$i 创建失败"
fi
fi
done
原文地址:https://www.cnblogs.com/wjxh/p/11597962.html
时间: 2024-12-29 07:14:51