In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you how the shell script to create users in batches, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
Shell script creates basic user operations in batches
Example: create a total of 20 files from user01 to user20 in batches with a random six-digit password and output the user name and password to the user.txt file
#! / bin/bash# batch create 20 users user01 ~ user20 user=user# create a file that stores users and passwords touch user.txttxt=user.txt# loop traverses 1 to 20for I in {1.. 20} do random=$ [$RANDOM0] if [$I-lt 10] Then name= "${user} 0$ I" useradd $name echo $random | passwd-- stdin $name & > / dev/null echo-e "$name $random\ t" > > $txt echo "$name created successfully" else name= "$user$i" useradd $name echo $random | passwd-- stdin $name & > / dev/null echo-e "$name $random\ t" > $txt echo "$name created successfully" fidone attached: create 50 users in batches with shell script and set password Delete users in bulk
Batch create 50 users and set passwords, delete users in batches.
The user name is required to be the same as the stu1-stu50 password.
# vim / rootspur adduser.shackle le i=1while binbase # batch create user "stu" i=1while [$I-le 50] douseradd ${PREFIX} $iecho "${PREFIX} $I" | passwd-- stdin ${PREFIX} $I & > / dev/null or userdel-r ${PREFIX} $I & > / dev/null: batch delete all the contents of the article "how shell scripts create users in batches". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.