您的位置:首页 > 运维架构 > Shell

批量添加删除用户(SHELL)

2009-11-25 16:20 766 查看
###############################################
#!/bin/bash
#the script act on a batch of add user,username at the same password
#If you have any suggestions for corrections,please leave me a comment, and I’ll check it out.
read -p "please input username and number(for example:xuanfei 100):" a b
for((i=1;i<=$b+1;i++))
do
useradd -m $a$i
echo "$a$i:$a$i" |chpasswd
pwconv && echo "add succeed :$a$i"
done
###############################################
#!/bin/bash
#the script act on delete user for the same The same features (for example:xuanfei1 xuanfei2 xuanfei3)
#If you have any suggestions for corrections,please leave me a comment, and I’ll check it out.
read -p "please input the username location (for example:xuanfei 1 100):" a b c
let d=$c-$b+1
for((i=1;i<=$d;i++))
do
userdel $a$b && echo "delete succeed:$a$b"
rm -rf /home/$a$b
let b=b+1
done
###############################################
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: