3.2 Shell Script - Quickly deleting a group of users

On occassion, it is necessary to remove user accounts. You can do this using server admin tools,but for speed, nothing beats a script.

The script described below deletes the user account of every user who is a member of a specified group. It then deletes the group itself. Use it with care!

Log in as "root" to the server that hosts the NetInfo master.  

Copy the rmusergroup.sh scripts into roots' home directory (/private/var/root/Documents)

 
Start a new shell.  

Change directory to roots' home directory, type:

cd ~/Documents

 

Make sure that the execute flag is set on the script "rmusergroup.sh" by typing:

chmod u+x rmusergroup.sh

Execute the "rmusergroup.sh" script as follows:

~/Documents/rmusergroup.sh group_name

The script will delete the user account of every user who is a member of the specified group. It then deletes the group itself.

USE WITH CARE!

If you don't specify a group on the command line - as follows:

~/Documents/rmusergroup.sh

The script will assume that you want to delete EVERY non-system user and group!

Mac OSX server - tech notes - © 2002 by Mark J Swift - msw AT blackpool.ac.uk