On Jan 23, 2008 11:33 AM, Joseph Hartman <[EMAIL PROTECTED]> wrote:
> I've been reading a lot of recommendations for giving each student their own
> account on the terminal server but I am loathe to go through the user
> creation process dozens of times for each class. Is there a mass user
> creation method I don't know about? Upload a .csv or something? Thanks -joe
>
Joseph (and Barb I added you too since you asked about this),
I have attached a script that someone wrote for me for this exact
purpose. I'm not 100% sure this is the debugged version so if anyone
wants to proof it (or improve it) that would be welcome help. I did
use this to add about 30 generic user names on our server. And it does
just do generic accounts (like user001, user002 or whatever you
choose) and the same password for all. Of course, passwords could be
changed later by the users.
Hope that helps.
Jim
--
Please avoid sending me Word or PowerPoint attachments.
See http://www.gnu.org/philosophy/no-word-attachments.html
#!/bin/bash
# Script to add a user to Linux system
COMMENT="WSD Thin Client User"
BASE_DIR="/home"
SHELL="/bin/sh"
if [ $(id -u) -eq 0 ]; then
typeset -i numuser
read -p "Enter number of users: " numuser
numuser=$numuser+1
read -p "Enter username prefix: " username
read -p "Enter group name: " groupname
read -s -p "Enter password : " password
pass=$(perl -e 'print crypt($ARGV[0], "password")' $password)
typeset -i index=1
until [ $index -eq $numuser ]
do
egrep "^${username}$index" /etc/passwd >/dev/null
if [ $? -eq 0 ]; then
echo ${username}$index exists, blitzing anyway!
userdel -r -f ${username}$index
#continue
else
useradd \
-c "${COMMENT}" \
-d "${BASE_DIR}/${username}$index" -m \
-g "${groupname}" \
-p "${pass}" \
-s "${SHELL}" \
${username}$index
[ $? -eq 0 ] && echo "User ${username}$index has been added to system!" ||
echo "Failed to add ${username}$index!"
fi
index=$index+1
done
else
echo Only root may add a user to the system
exit 2
fi
--
edubuntu-users mailing list
[email protected]
Modify settings or unsubscribe at:
https://lists.ubuntu.com/mailman/listinfo/edubuntu-users