General discussion

Locked

Bulk creation of users on HP-UX system

By stevelil ·
What is the best way to create several hundred new users in one go. Making sure it's easy to maintain the structure of the set ups in the future.

This conversation is currently closed to new comments.

3 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Bulk creation of users on HP-UX system

by cpfeiffe In reply to Bulk creation of users on ...

for USER in `cat filename`
do
user=`echo $USER|awk '{print $1}'`
group=`echo $USER|awk '{print $2}'`
useradd -g $group -d /home/$user -s /bin/ksh -m -k /etc/skel $user
done

Now let me explain.
First I am assuming you will be able to add theusernames (i.e. juser) to a text file. If you are assigning different users to different groups I am assuming you'll be able to add the group IDs (i.e. 20) to the same text file on the same line as the username separated by one or more space. Yourtext file might look like
juser 20
kuser 20
luser 21

Now, you run the for loop against the file (filename as called by the loop). For each line in the file it is setting the username to the first field (juser, kuser, etc) via the awk parser and setting the group to the second field in the same manner. Then we just use useradd to add the users. If you want all users in the same group you can skip the group variable setting and in the useradd command you can replace $group with the groupID you wish to assing to every user. You can look up useradd to make modifications to how you want this to work, you will have several options. The basics here are to set up a text file that you can loop against and run useradd against each line of the text file. Now you will have to set passwords as well for each user or set the account up with no password and let them set it the first time they log in. You have many password options as well, and depending on what you decide to do you canloop this process as well. I hope this helps. Good luck.

Collapse -

Bulk creation of users on HP-UX system

by stevelil In reply to Bulk creation of users on ...

Poster rated this answer

Collapse -

Bulk creation of users on HP-UX system

by stevelil In reply to Bulk creation of users on ...

This question was closed by the author

Back to Linux Forum
3 total posts (Page 1 of 1)  

Related Discussions

Related Forums