Batch create users in Linux

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.