How to quickly (batch) make new /home/dir

Say you have a new machine, and it is not on NIS or LDAP, it needs to be really secure and only have local accounts. So you need to make a bunch of local accounts, but you need to leave for lunch in a half hour. Well simply use this short simple script to make them and set the proper permissions in a matter of seconds. Below is a sample script, I suggest calling is something like createuserhomedir.sh. We are assuming that there is a file called users which has all the user’s name that we want to make in the same directory as the script.

#!/bin/sh
mkdir=/bin/mkdir

echo “echoing users”
cat ./users
echo “end echoing users”
echo “Making Home Directories”
for i in `cat ./users`
do
mkdir /export/home/$i
echo “Fixing Permissions For $i Home DIR’s”
chown -R $i:other /export/home/$i
done