Batch Create user (Shell command) under Linux

Source: Internet
Author: User

The first method:
Using Shell to create users in bulk, divided into 2:1, batch-created user names are irregular; 2. batch-created user names are regular
First, the shell of the user name that was created in bulk is irregular:
First, the user names that need to be created in bulk are listed in a text document, such as the UserList file
Then the password matching the user name is listed in another text document, such as the passwd file



The contents of both text documents are as follows:


Here is the shell script I wrote. As shown

Note that you need to import the user name that we wrote in UserList and the password entry that matches the user name written in passwd
Note:
CHPASSWD command
#以root的身份执行/USR/SBIN/CHPASSWD,CHPASSWD writes a password that has been compiled/USR/BIN/PASSWD command to the/etc/passwd password bar
Pwconv command
After #确定密码经密码写入 the/etc/passwd password bar, execute the command/usr/sbin/pwconv command to compile the password to shadow password and write the result to/etc/shadow
Give this shell script permission to X, and here I am 700.
The command is: #chmod 700/root/desktop/user/create.sh
Then execute this shell script
The command is: #./create,sh
The effect is as follows:



Ok,success
To demonstrate the second shell, I also wrote a shell script to delete the user in bulk, removing the user from the above, as shown in:





Ok
Second, I would say that the batch creation of user names is a regular time
Here, there is no need to use the above mentioned text document, so troublesome, directly written into the shell can













Yes, success.

Batch Create user (Shell command) under Linux

Related Article

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.