i am trying to write a script to add 100 users and with certain things created. however, all the book and tutorials online recommend and only show the way to use passwd user after creating a user by useradd username.

i know there is a -p option for the password

and i tried:

useradd name -p password -c "comment" -g 600

this user was created, everything else is fine except for the password. i couldn't log in this user with the password i set with the -p . does anybody know how i should useradd and set the password? thank you

Hey There,

You're probably running into an issue with -p if you're just using a plaintext password. It expects the password to be encrypted using the crypt program (apologies if my assumption is incorrect.

One thing I was thinking was that it might be easier to create the script to add the 100 users, but have two lines (or comma separated single lines) with one doing the standard useradd and the other using "passwd" with the "--stdin" option, which you can automate with a pipe,

useradd allYourOptionsExceptPassword user1
echo Myp@ssworD|passwd --stdin user1

Some food for thought anyway. Hope it helps!

Best wishes,


thank you, that works perfectly in bash. Now i am trying to translate it into perl. i guess i'll post my another question in the perl page.

Good deal :)

Glad to help!

, Mike