#!/bin/bash
#
#
read -p "keyin add or del: " keyin
for i in `seq -w 10`;do
password=user$i`echo $RANDOM | md5sum | cut -c 1-5`
case $keyin in
add)
if ! id user$i &> /dev/null ;then
useradd user$i &> /dev/null
echo $password | passwd --stdin user$i &> /dev/null
echo "user$i has added"
echo "user:user$i pwd:$password" >> /tmp/usertest
else
echo "user$i cunzai"
fi;;
del)
if id user$i &> /dev/null;then
userdel -r user$i &> /dev/null
echo "user$i has deleted"
> /tmp/usertest
else
echo "user$i bu cunzai"
fi;;
*)
exit 1;;
esac
done
时间: 2024-10-23 13:37:07