Linux: adding multiple users in batch

Title:

Linux: adding multiple users in batch

Author:

Douglas O’Leary <dkoleary@olearycomputers.com>

Description:

Linux: adding multiple users in batch

Date created:

08/2000

Date updated:

09/2009

Disclaimer:

Standard: Use the information that follows at your own risk. If you screw up a system, don’t blame it on me…

This ought to make peoples lives a whole lot easier. This little tip was posted in the comp.os.linux.misc newsgroup on/about 17 Aug 2000 by Peter Herttrich of Denmark.

Standard problem: How to add hundreds of users with passwords without having to issue password for every single user. The standard answer for the major OSs is to use an expect script or write something in perl. Bit of a pain. Along comes Linux with the /usr/sbin/newusers program.

The command takes a file that contains passwd file formatted entries for each user. The man page is a little vague on the format for the file. So, an example of the users file is included:

test1:3biteme:600:100:testing:/home/test1:/bin/bash
test2:3biteme:601:100:testing:/home/test2:/bin/bash
test3:3biteme:602:100:testing:/home/test3:/bin/bash
test4:3biteme:603:100:testing:/home/test4:/bin/bash
test5:3biteme:604:100:testing:/home/test5:/bin/bash
test6:3biteme:605:100:testing:/home/test6:/bin/bash
test7:3biteme:606:100:testing:/home/test7:/bin/bash
test8:3biteme:607:100:testing:/home/test8:/bin/bash
test9:3biteme:608:100:testing:/home/test9:/bin/bash
test10:3biteme:609:100:testing:/home/test10:/bin/bash
test11:3biteme:610:100:testing:/home/test11:/bin/bash
test12:3biteme:611:100:testing:/home/test12:/bin/bash
test13:3biteme:612:100:testing:/home/test13:/bin/bash
test14:3biteme:613:100:testing:/home/test14:/bin/bash
test15:3biteme:614:100:testing:/home/test15:/bin/bash

Remember to keep the passwords in the clear and the user file @ 600 permissions.

The program’s damned fast too; I added 50 test users on a Pentium 200 in under 1 second. The only issue is that it doesn’t automatically copy the /etc/skel/* files into the new users’ home directories. Oh, well; can’t have everything…