Linux: How To Create Multiple Users Accounts in Batch
This is useful at universities or large corporate Linux networks. Adding users in batch saves the time.
Task: Set Password
Type the following command to change or set user password:echo "username:password" | newusers
For example, change user password for vivek user:
echo "Vishvendra:Password" | newusers
Task: Update and create new users in batch
newusers command reads a file of user name and clear-text password pairs and uses this information to update a group of existing users or to create new users. Each line is in the same format as the standard password file.This command is intended to be used in a large system environment where many accounts are updated at a single time (batch mode). Since username and passwords are stored in clear text format make sure only root can read/write the file. Use chmod command:
# touch /root/batch-user-add.txt
# chmod 0600 /root/batch-user-add.txt
Create a user list as follows. Open file:
# vi /root/batch-user-add.txt
Append username and password:
user1:password:1001:513:Student Account:/home/user1:/bin/bash
user2:password:1002:513:Sales user:/home/user2:/bin/bash
user100:password:1100:513:Sales user:/home/user100:/bin/bash
tom:password:1110:501:Guest Account:/home/guest:/bin/menu
jerry:password:1120:501:Guest Account:/home/guest:/bin/menu
Now, create users in batch:
# newusers /root/batch-user-add.txt
Verify that your /etc/group, /etc/passwd and /etc/shadow files are updated:
less /etc/group
less /etc/passwd
less /etc/shadow
Comments
Post a Comment