Detailed introduction to the creation of Linux batch users

Source: Internet
Author: User

It is relatively simple for a Linux administrator to create and delete users. However, if you want to create multiple users in Linux, I believe that users who have just learned Linux system management will still find it tricky, this problem is fully taken into account in the Linux system. The following describes how to solve the problem of Linux batch User Creation.

Linux provides a tool to create a large number of users, allowing you to create a large number of users immediately, as follows:
1) edit a text user file. Each column is written in the format of the/etc/passwd password file. Note that the user name, UID, and home directory of each user cannot be the same, the password column can be left blank or enter the x number. The content of user.txt in a sample file is as follows:
User001: 600: 100: user:/home/user001:/bin/bash
User002: 601: 100: user:/home/user002:/bin/bash
User003: 602: 100: user:/home/user003:/bin/bash
User004: 603: 100: user:/home/user004:/bin/bash
User005: 604: 100: user:/home/user005:/bin/bash
User006: 605: 100: user:/home/user006:/bin/bash
2) run the command/usr/sbin/newusers as root to import data from the user file user.txt, and create the user:
# Newusers <user.txt
Then, run vipw or vi/etc/passwd to check whether the data of these users is displayed in the/etc/passwd file and whether the user's home directory has been created.
3) run the/usr/sbin/pwunconv command to decode the shadow password generated by/etc/shadow and write it back to/etc/passwd, delete the shadow password column of/etc/shadow. This is to facilitate the next step in password conversion, that is, to cancel the shadow password function first.
# Pwunconv
4. Edit the password reference file for each user. The content of the example file passwd.txt is as follows:
User001: Password
User002: Password
User003: Password
User004: Password
User005: Password
User006: Password
5) run the command/usr/sbin/chpasswd as root to create the user password, chpasswd writes the password encoded by the/usr/bin/passwd command to the/etc/passwd password column.
# Chpasswd <passwd.txt
6) Confirm that the password is encoded into the/etc/passwd password column, execute the command/usr/sbin/pwconv to encode the password as shadow password, and write the result into/etc/shadow.
# Pwconv
This completes the creation of Linux batch users. Then, you can go to/home to check whether the permission settings of these users in the home directory are correct, and log on to verify that the user password is correct.

  1. In-depth analysis of Linux partition Basics
  2. Detailed analysis of Linux Process Scheduling time
  3. Detailed command 1 for running Linux background)
  4. Comprehensive parsing of Linux profile files
  5. Brief Introduction to Linux kernel Security Intrusion Detection System

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.