HPE Community read-only access December 15, 2018
This is a maintenance upgrade. You will be able to read articles and posts, but not post or reply.
Hours:
Dec 15, 4:00 am to 10:00 am UTC
Dec 14, 10:00 pm CST to Dec 15, 4:00 am CST
Dec 14, 8:00 pm PST to Dec 15, 2:00 am PST
cancel
Showing results for 
Search instead for 
Did you mean: 

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
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.