Playing with Autodir


We will create some 1000 user accounts on the local system. First download users.txt file. It contains all the account names to be created. Then execute the following shell script as root user.

-----------SCRIPT START------------

#!/bin/sh
#
# Script to add user accounts to the local system
# for use by Autodir.
#
homebase="/test"

for user in `cat users.txt`
do
        echo "adding user $user"
        useradd $user -d "$homebase/$user" -M
done

--Output from script--

adding user user_1000
adding user user_1001
adding user user_1002
adding user user_1003
adding user user_1004
adding user user_1005
adding user user_1006
adding user user_1007
adding user user_1008
...
...
...

In the above shell script, we add users with home directory /test as base. We do not use /home for these accounts as home directory so you can feel comfortable and in control. Option -M causes not to create actual home directories in the directory /test so that we can simulate as if we imported these accounts from LDAP/SQL/NIS.