An easy way to do this in a script is to echo something into the passwd command. If you do, you'll need to add the --stdin option for passwd. Depending on the password that you set, you may want to force your new users to change their passwords the first time they log in. This can be accomplished with chage -d0. Here's a simple bash for loop that demonstrates this. It will add four users, set their passwords to be the same thing as their usernames, and force them to change their password the first time they log in.
for NAME in mike brian chris susan; do useradd $NAME; echo $NAME | passwd --stdin $NAME; chage -d0 $NAME; done
Last edited by colucix; 08-24-2011 at 11:00 AM.
Reason: link to commercial site removed. No advertising allowed here.