In Linux, there are two ways to create users in batches:
Method 1:
1. Create a new file user.txt with/etc/passwd as the template
2. Create a new file passwd..txt with the/etc/shadow as the template.
3. Prepare to create
Command: newusers <user.txt
4. Set a password for the Account
Command: chpasswd <passwd.txt
5. Synchronize shadow with the user name account
Command: pwconv
6. Add the system configuration file to your main folder.
Cp-a/etc/skel/./home/user7/
Cp-a/etc/skel/./home/user8/
Cp-a/etc/skel/./home/user9/
7. Batch creation is complete.
Method 2:
Use a script (the user must be 'English + number)
The first line indicates a comment.
Output during execution of the second and third rows
Line 4 and line 5 indicate the last part of the input user, that is, the number part.
The sixth flight indicates extracting the front of the input user, that is, the front of the number.
Row 7 uses the for statement
The ninth line creates a user and uses the combination of the extracted two parts.
The tenth line creates a password, but all user passwords created in batch are the same as 123
Line 1 done ends
Execute the script file bash useradd. sh enter two users as prompted, but the last number of user names entered for the second time is greater than that entered for the first time. In this way, all users in the middle are created successfully.
How to create multiple users in Linux
Batch add users in Linux
How to create a user on SUSE Linux
How to add multiple users in Linux