Script required to create many user accounts

Dennis Kaarsemaker dennis at
Tue Jan 31 13:20:05 UTC 2006

On di, 2006-01-31 at 14:55 +0200, Hendrik Boshoff wrote:
> Hi
> I have created a file with details of 360 children to whom I want to
> give access to our Edubuntu lab. It is a comma separated variable with
> the following fields:
>   username, full name, password, group1, group2
> Can someone help with a script to create these users in a batch, and
> give them membership of both groups?
> The passwords are based on a standard pattern including their birthday.
> Not ideal, but I want to create a mailmerge letter to each containing
> their particulars. They will be encouraged to choose their own password
> once they have log'd on. (Is there a way to pre-expire a password?)

I use something like this for batch-adding, simply pipe the file into


while [ 0 ]; do
    read LINE
    USER=`echo $LINE | cut -f 1 -d ,`
    FULLNAME=`echo $LINE | cut -f 2 -d ,`
    PASSWORD=`echo $LINE | cut -f 3 -d ,`
    GROUP1=`echo $LINE | cut -f 4 -d ,`
    GROUP2=`echo $LINE | cut -f 5 -d ,`

    if [ x"$USER" == x ]; then

    # Generate password
    for I in seq 8; do
        SALT=${SALT}${CHARS:$((RANDOM % ${#CHARS})):1}

    # Create user
    echo "Adding user '$USER, $FULLNAME'"
    adduser --disabled-password --gecos "$FULLNAME,,," $USER
    usermod -p `echo $PWD | mkpasswd --salt $SALT --hash md5 --stdin` $USER
    adduser $USER $GROUP1
    adduser $USER $GROUP2

Dennis K.
  - Linux for human beings:
  - Linux voor iedereen:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <>

More information about the edubuntu-devel mailing list