1754984 Members
2667 Online
108828 Solutions
New Discussion юеВ

useradd command

 
SOLVED
Go to solution
rajesh73
Super Advisor

useradd command

i want to creat 20 user account in one single command .it is possible ?
6 REPLIES 6
Steven Schweda
Honored Contributor
Solution

Re: useradd command

Sure, it's possible, but it may not be very
smart. How do you intend to specify all the
different parameters for all these accounts?
Why would one command be better than N
commands for creating N user accounts?
rajesh73
Super Advisor

Re: useradd command

ok. as per your messge ,one by one only we able to create. thats corect
vishnu.khandare
Respected Contributor

Re: useradd command

Hi Rajesh,

Yes, its very correct u can create N no of user in single command.

But its best practice is to create user one by one, so that if u want to give different parameters u can provide. like shell ,group etc.

Hope ur query resolved.

Regards
Vishnu Khandare
You should deserve before U desire!!!!
rariasn
Honored Contributor

Re: useradd command

Hi Rajesh:

Creatre user file sample:

# cat /tmp/users.txt
user1
user2
...

# for USER in $(cat /tmp/user,txt)
do

useradd -g XX -s /usr/bin/ksh -m -d /home/$USER $USER

done

# man useradd

rgs,
щ╗ЮчЗГ
Valued Contributor

Re: useradd command

saludos

As given above, a simple "for" loop would do it for you, however with common options. In the other hand, you can have a more complex script which runs interactively and asks for the 'list' of user names and to choose options for them like group, shell etc.(many admins use scripts of this sort for user admin)
Still these will be creating the users "one by one" , not in a single shot. :D

todo lo mejor
Man's mind, once stretched by a new idea, never regains its original dimensions
Hiren N Dave
Valued Contributor

Re: useradd command

> i want to creat 20 user account in one single command .it is possible ?

No, it is not possible to create 20 user accounts in one single command unless you create series of commands in a script file as given by rariasn. But this way you will have very limited/common options for each users and after creating all users, you will have to supply passwords one by one, can't do this in one go.

I would use simple way, copy previous command and edit to change username and other options instead writing scripts unless you have to use it frequently to create bunch of users on daily basis!!!
I am an HP Employee

Was this post useful? - You may click the KUDOS! star to say thank you.