Linux users add bulk

  1, the first user to edit a text file:

    Each column in accordance with the /etc/passwdformat of writing the password file, pay attention to each user's user name, UID, can not host the same directory where the password field can be left blank or enter x number do. User.txt a sample file reads 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, execute the command as root  /usr/sbin/newusers, the file you just created from the user user.txtto import data, create a user:  

# newusers < user.txt

You can then execute the command  vipw or  vi /etc/passwd check  /etc/passwd file these data whether the user has occurred, and whether the user's home directory has been created.

       3, execute the command / usr / sbin / pwunconv

The  /etc/shadow generated  shadow code decoding, and then written back  /etc/passwd in, and /etc/shadowthe shadowpassword field deleted. This is to facilitate the next step of the cryptographic transformation work, which is to cancel the  shadow password function.

# pwunconv

  4, edit each user's password control file.

  Sample files  passwd.txt as follows:

user001: Password 
user002: Password 
user003: Password 
user004: Password 
user005: Password 
user006: Password

       5, execute commands as root  /usr/sbin/chpasswd.

Create a user password, chpasswd it will pass  /usr/bin/passwd encoded command code written  /etc/passwd password bar.

# chpasswd < passwd.txt

    6, to determine the password encoded write / etc / passwd password field after.

Run  /usr/sbin/pwconv password encoded  shadow password, and writes the result  /etc/shadow.

# pwconv

This completes the creation of a large number of users, after which you can go to the / home user home directory permissions for these check whether the settings are correct, and user login authentication password is correct.

 Reference:https://www.runoob.com/linux/linux-comm-tee.html

Guess you like

Origin www.cnblogs.com/revel171226/p/11440998.html