linux redhat shell 脚本 批量添加用户

2020-09-14 教育 85阅读
#!/bin/sh
i=0
while true
do
let i=i+1
echo "u"$i":123456" >>/root/user.txt
echo "createing user u$i ................."
useradd u$i
if [ $i -eq 100 ]
then
/usr/sbin/chpasswd /root/user.txt
/bin/rm -f /root/user.txt
exit
fi
done
#if you want to delete all of the user,you can
#i=0
#while true
#do
# let i=i+1
# echo "deleteing user u$i ................."
# userdel -r u$i
# if [ $i -eq 100 ]
# then
# exit
# fi
#done
供参考
声明:你问我答网所有作品(图文、音视频)均由用户自行上传分享,仅供网友学习交流。若您的权利被侵害,请联系fangmu6661024@163.com