Previous Section  < Day Day Up >  Next Section

Recipe 8.12. Deleting Groups with groupdel

8.12.1 Problem

You need to delete a group or groups, and you want to be sure there are no orphaned files or users.

8.12.2 Solution

First reassign the group members, if necessary, by editing /etc/group. Simply copy and paste them into another group. Then use groupdel to delete the group, and find and chgrp to locate and reassign the group's files to another group.

To delete a group use:

# groupdel 


groupname

Deleting a group tends to be messy, because there is no utility for automatically migrating or deleting any files or users belonging to the group. You'll need to hunt these down and change the GIDs manually:

# find / -gid 750

/usr/src/include/lber.h

/usr/src/include/ldap.h

/usr/src/include/ldbm.h

You can change these one at a time:

# chgrp 800 /usr/src/include/lber.h

Or you can let find and chgrp do the work:

# find / -gid 750 -exec chgrp -v  800 {  } \;

8.12.3 See Also

  • groupdel(8), find(1), chgrp(1)

  • Recipe 8.6, for an explanation of how the find command works in these examples

    Previous Section  < Day Day Up >  Next Section