Here is a small script to batch add users from your linux system:

First you need to install pwcrypt it is a command line interface to the crypt() function. It is handy for use in generating encrypted passwords via a command line interface.

Debian and Ubuntu users click here.

Redhat and Fedora users click here.

Next you need to create a new text file with the list of your user in this format, one per line, save this as newusers.txt

name1 password1 fullname1

name2 password2 fullname2

Now you need to be a root user to run this script. save this script as newuser

#!/bin/bash

cat newusers.txt | while read u p n
do
useradd –comment “$n” –password $(pwcrypt $p) –create-home $u
passwd -e $u
done

In order to run the script change the file permission using this command chmod 750 newuser. Running this script will create a new user and with the password that you have on your text file and will immediately expires the passwords so better inform your user to change their password after they login.

Like this blog? Why not buy me a cup of coffee?