[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Create new users in a special way

On Fri, Jun 29, 2001 at 11:45:20AM +0200, Heidelinde Meier wrote:
> Hello!
> Perhaps my question is not too difficult for you to answer: I want to
> create more than 5000 new users on my system.  Because there are 5000
> users who already got their password, that means for me: I already got
> the complete files /etc/passwd and /etc/shadow on my system.
> Now I want to create /home/directories in the way the programm "adduser"
> create /home/directories /copying files from /etc/skel and copy them in
> user's home directory, and so on.
I have written a script to do this sort of thing, to manage our school
users (approx 1200 users). It's called foreachuser and can do things like
this, perhaps with a little perl wraparound.

You can get all user names out of the passwd file and seperate them with
commata with something like 

	USERLIST=`cut -d: -f1 < /etc/passwd | perl -pe 's/\n/,/g'`

Then you use perhaps something like

	foreachuser -u $USERLIST '-d HOME || cp -a /etc/skel HOME && chown USER.GROUP HOME'

after (!) you have copied the new passwd/group/shadow files to /etc,
because the foreachuser script extracts them from there.

I attached the files you need.

WARNING: The help text doesn't give you (yet) the correct parameters (and
I'm not even sure about the above ones). Try them and READ THE SOURCE
first. I haven't used this beast in a while.

But do tell me if I solved your problem. ;)

Jens Benecke
http://www.hitchhikers.de/ - Die kostenlose Mitfahrzentrale für ganz Europa

Attachment: foreachuser.pl
Description: Perl program

Attachment: pgpvJPJ4YgXO7.pgp
Description: PGP signature

Reply to: