Simple scripts to automate creation of users


make_users_slack.sh

#!/bin/bash
 
# Make users from text file (in Slackware)
# Copyleft Fabio Zorba - 2006
 
if test $# -ne 1
then
 echo "Usage: $0 list_users_text_file"
 exit 1
fi
 
IFS=:
cat $1 |
while
 read user_ desc_ pass_ group_
do
 
 echo "Username: $user_ Pass: $pass_  Desc: $desc_ Group: $group_"
 
 PASSWORD_=`echo $pass_ | /usr/sbin/ftpasswd --hash --md5 --stdin | cut -d":" -f2 | cut -d" " -f2`
 
 useradd -g $group_ -c "$desc_" -m -k /etc/skel -s /bin/bash -d "/home/$user_" -f -1 -p `echo "$PASSWORD_"` $user_
 
 chmod 700 /home/$user_
 
done

remove_users_slack.sh

#!/bin/bash
 
if test $# -ne 1
then
 echo "Usage: $0 list_users_text_file"
 exit 1
fi
 
IFS=:
cat $1 |
while
 read user_ desc_ pass_
do
 
 echo "Deleting $user_ and user home"
 
 smbpasswd -x $user_
 
 userdel -r $user_
 
done
Retrieved from "http://www.zoros.org/wiki/index.php?title=Make_users_script_in_Slackware"