#!/bin/bash
# 创建用户个数
read -p "请输入你要创建用户的个数: " -t 30 num
echo -e "\e[1;31m开始添加用户\e[0m"
while [ $num -gt 0 ]
do
useradd nodeuser$num &>/dev/null
echo -e "first$num" | passwd --stdin nodeuser$num &> /dev/null
num=$(($num-1))
done
unset $num &>/dev/null
echo -e "\e[1;31m添加完成\e[0m"
cat /etc/passwd | grep nodeuser
删除用户
#!/bin/bash
# author:shujiangle
num=$(cat /etc/passwd | grep nodeuser | cut -d ":" -f 1)
for i in $num
do
userdel -r $i &> /dev/null
done
unset num
echo "删除完成"
cat /etc/passwd | grep nodeuser
网友评论