#!/bin/bash
#
#添加10个用户user1到user10,密码同用户名:但要求只有在用户不存在的情况下才能添加;
#删除10个用户user1到user10
if [ $# -lt 1 ];then
echo "Usage:`basename $0` ARG"
exit 7
fi
if [ $1 == add ];then
for I in {1..10};do
if id user$I &> /dev/null
then
echo "the user$I exist."
else
useradd user$I && echo "user$I" | passwd --stdin user$I &> /dev/null
echo "add user$I success."
fi
done
elif [ $1 == del ];then
for I in {1..10};do
if id user$I &> /dev/null
then
userdel -r user$I
echo "delete user$I ."
else
echo "the user$I not exist."
fi
done
else
echo such as user
fi
时间: 2024-11-10 01:05:55