Download this file


#!/bin/ksh
# Shell script to remove a user account from the system.  This script uses
# the "smit" command "rmuser" to do most of the work for us.
# Use this script in a loop to remove a bunch of (student) accounts at once:
#       for i in a b c
#       do      for j in 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20
#               do      rmusr u$i$j
#               done
#       done
#
# Written by Wayne Pollock, Tampa Florida, 2001.

if [ "$1" = "" ]
then    echo You must say who to remove! >&2
        exit -1
fi
case "$1" in
    u?+([0-9]))   ;;  # eg, "ua01" (remove student accounts without asking first)
    *)
        echo "Are you sure you want to remove account \"$1\" (y or n) ?"
        read answer
        case "$answer" in
            [yY]*)        ;;
            *)      echo "*** account \"$1\" not removed!"
                    exit -1
                    ;;
        esac
        ;;
esac
/usr/sbin/rmuser  '-p' $1
/usr/bin/rm -rf /home/$1
# look (in /var/spool on a modern system) for mailbox, crontab, printer, at jobs, etc.:
find /usr/spool -name $i -print | xargs /usr/bin/rm -f
echo "User \"$1\" has been completely removed from the system!"




Send comments and questions to pollock@acm.org.