How shell scripts create users in batches
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!