| | |
useradd question
Thread Solved |
•
•
Join Date: Nov 2007
Posts: 227
Reputation:
Solved Threads: 0
hi,
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:
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
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:
Shell Scripting Syntax (Toggle Plain Text)
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
•
•
Join Date: Oct 2007
Posts: 399
Reputation:
Solved Threads: 47
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,
Some food for thought anyway. Hope it helps!
Best wishes,
Mike
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
Best wishes,
Mike
Linux and Unix Tips, Tricks and Individual Advice - The Linux and Unix Menagerie!
------------------------------------------------------------------------
The greatest viral marketing idea of all time, get your copy of this Free Report now!
------------------------------------------------------------------------
The greatest viral marketing idea of all time, get your copy of this Free Report now!
•
•
Join Date: Oct 2007
Posts: 399
Reputation:
Solved Threads: 47
Good deal 
Glad to help!
, Mike

Glad to help!
, Mike
Linux and Unix Tips, Tricks and Individual Advice - The Linux and Unix Menagerie!
------------------------------------------------------------------------
The greatest viral marketing idea of all time, get your copy of this Free Report now!
------------------------------------------------------------------------
The greatest viral marketing idea of all time, get your copy of this Free Report now!
![]() |
Similar Threads
- cannot authenticate user/ yum question (*nix Software)
Other Threads in the Shell Scripting Forum
- Previous Thread: Which shell program does XP pro use?
- Next Thread: File doesn't update data
| Thread Tools | Search this Thread |





