Tuesday, June 16, 2015

How to create multiple user at the time in only one command?

Simple command or script to to create multiple user at the time.

[root@localhost]# newusers

(# newusers /root/batch-user-add.txt ) you can use this command for creating a number of users at a time. try it once and check the status.

Try this :- for man info
[root@localhost]# man newusers


Linux newusers Command — Creating bulk users

Sometimes you may want to to create multiple users at the same time. Using the normal methods for bulk user creation can be very tedious and time consuming. Fortunately, Linux offers a way to upload users using new users command. This can also be executed in batch mode as it cannot ask any input.

# newusers FILENAME

This file format is same as the password file.

loginname:password:uid:gid:comment:home_dir:shell


Shell script logic: 

You can use a for loop:

for i in frank alex chandler teja
do
useradd $i
done





OR

for i in `cat users.txt`
do
useradd $i
done

No comments:

Post a Comment