美文网首页
linux 创建任意的用户个数

linux 创建任意的用户个数

作者: 独钓寒江sjl | 来源:发表于2018-11-27 11:31 被阅读0次
#!/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

相关文章

网友评论

      本文标题:linux 创建任意的用户个数

      本文链接:https://www.haomeiwen.com/subject/seqgqqtx.html