Script: add_users.sh

Script Name

add_users.sh

Script Summary

Add users to a system en-masse.

Script Description

This script will read a list of space separated Firstname Lastname entries, one per line, from a file specified. It will create an appropriate group (specified within the script) to add users to if it doesn’t already exist. If the group does exist, the users will be created via useradd and a random password set, and those passwords outputted to STDOUT.

Script Limitations

  • Only tested on RHEL/OEL/CentOS 5.x and 6.x.
  • Will handle duplicate usernames semi-gracefully by exiting with an error, rather than doing anything fancy - you’ll need to add those users manually

Sample Input/Output

Or with duplicate usernames:

Script