Article Title: create multiple users in linux. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
(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:
Format reference/etc/passwd
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.txt file of the created user 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 comparison file for each user. The content of the example file passwd.txt is as follows:
Format reference/etc/shadow
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, and then execute the command/usr/sbin/pwconv to encode the password as shadow password, write the result to/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.