[techtalk] mass useradd

Aaron Malone aaron at mancala.semo.net
Mon Jun 26 16:35:37 EST 2000


On Thu, Jun 15, 2000 at 10:57:36AM -0400, Brian Sweeney wrote:
> Hello all-
> 
> Haven't been on the list in a while...hope everyone's doing well in their
> endeavors.  I have what I hope is a quick question.  I would like to know if
> there's a way (possible using perl/expect?) to add multiple users from a
> text file list all simultaneously.   I figure I could either put the
> usernames and passwords in one file (deliminating them with commas, spaces,
> tabs, <CR>, whatever), or put the username list in one file and the password
> list in another.
[snip]
> Is there a built-in linux command to do this, or does anyone know of a good
> script?

(Sorry my response is so delayed, I hardly ever read techtalk anymore.)

As a matter of fact, there's a program that does exactly what you're
looking for: chpasswd(8).  It takes a file of format:

aaron:foo887
josh:farglebog
pete:monkeypants

read from stdin (that is, "cat new-passwords.txt|chpasswd" or similar)
and updates the password files accordingly.

-- 
Aaron Malone (aaron at semo.net)
System Administrator                  "Of course I'm crazy, but that 
Poplar Bluff Internet, Inc.                doesn't mean I'm wrong."
http://www.semo.net                           -- Robert Anton Wilson





More information about the Techtalk mailing list