1752785 Members
5953 Online
108789 Solutions
New Discussion юеВ

Re: useradd

 
SOLVED
Go to solution
himacs
Super Advisor

useradd

hi admins,

i want to create 5 users at a time means using single command i want to create 5 users.

plz help me on this

regards,
himacs
6 REPLIES 6
James R. Ferguson
Acclaimed Contributor

Re: useradd

Hi Himacs:

I posted a simple script that reads its input from a file just yesterday in this thread:

http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1353860

Regards!

...JRF...
Ganesan R
Honored Contributor

Re: useradd

Hi Himacs,

Useradd command takes single login input by default. You can use for loop like this..

for USER in user1 user2 user3 user4 user5
do
useradd -m $USER
done

This will create the users with default shell, default group. If you want specific shell, specific group or specific command, you can pass the informations to the useradd command.

useradd -g -s -c "comment if any> -m $USER
Best wishes,

Ganesh.
himacs
Super Advisor

Re: useradd

Hi James,Ganesan,

thanx for ur reply..it was useful.
plz let me know any option with useradd command to create multiple users at a time,without using script.


regards,
himacs
James R. Ferguson
Acclaimed Contributor

Re: useradd

Hi (again) Himacs:

> plz let me know any option with useradd command to create multiple users at a time, without using script.

Define "script". If I write more than one command on the command line is that considered a script or not? If the multiple commands and operators don't easily fit in (for example) an 80-character command line and I then put them into a file for repeated use and/or maintainability, that's generally called a "script".

Why are you so concerned here?

With regard to 'useradd' the anwser to your question is "no".

Regards!

...JRF...
himacs
Super Advisor

Re: useradd

Hi James,

thanks

let me use script for the same..

regards
himacs
Ganesan R
Honored Contributor
Solution

Re: useradd

Hi Himacs,

>>>plz let me know any option with useradd command to create multiple users at a time,without using script.<<<

This I have answered in my previous reply. useradd command will not accept more than one username as arguments. You can check the man page.
Best wishes,

Ganesh.