前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >批量添加用户和批量删除用户脚本

批量添加用户和批量删除用户脚本

作者头像
BGBiao
发布2018-02-26 10:39:31
2.2K0
发布2018-02-26 10:39:31
举报
文章被收录于专栏:容器云生态

批量添加用户

[root@heart2 sh]# cat useradd.sh #!/bin/bash #The script is used to add a lot user. #Author:xxbandy by 27/5/14 #If you have any opinion,you can contact me by email:weichuangxxb@sina.cn #You want to add the name of user echo -n -e "Please inout your name :" read username #The num of user echo -n  "Please input num:" read num #The users'name n=1 while [ $n -le $num ] do         useradd $username$n         n=`expr $n + 1` done #The users'password echo -n -e "please input your passwd:" read passwd m=1 while [ $m -le $num ] do         echo $passwd | passwd --stdin $username$m         m=`expr $m + 1` done #

批量删除用户

[root@heart2 sh]# cat deluser.sh #!/bin/bash ##The script is used to delete a lot user. #Author:xxbandy by 27/5/14 #If you have any opinion,you can contact me by email:weichuangxxb@sina.cn # #You want to delete username echo "please input your name:" read name echo "please input num:" read num sum=0 while [ $sum -lt $num ] do sum=`expr $sum + 1` userdel -r $name$sum done

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档