SUMMARY: Change UID and Deleting Users

From: Boylan (
Date: Thu Feb 25 1993 - 22:36:37 CST

Here is a summary (overdue) of responses to my questions about how to change
UID's and delete users.

A. Changing UID

1) Edit the userid numbers in /etc/passwd file. If NIS is running, then
execute a ypmake passwd. Then find all the files owned by that user and
execute a chown on those files;

find . -user <old userid> -exec chown <new userid> {}\;

2) Essentially the same approach, but in a small shell script;

#Needs to be run on every server on your network that has this userid
OLDUID= <old userid>
NEWUID=<new userid>
for DIR in `egrep 4.2 /etc/fstab | awk '{print$1}'`; do
 find $DIR -user $OLDUID -exec chown $NEWUID {}\;

3) Use sed

4) Use vipw.

B. Deleting Users

1) Essentially the same approach as changing UID's but delete entries from
/etc/passwd file and execute rm in find statement instead of chown.

Thanks for all the help on this, especially:

Evan L. Marcus (
Hao Wang ( Has shell script for delete.
Jon Brewster (
Chris Bulle (chris@invmms.WorldBank.Org)
Douglas L. Acker ( Has some perl scripts.
Jean Chouanard (
Steve Elliot ( Recommends good book.
Badri Pillai ( Has C program.
Hal Stern (stern@sunne.East.Sun.COM)
Michael G. Harrington (
Perry Hutchison (
Mike Raffety (

Thanks again -

John G. Boylan
Director - NMR Facility
Boston College
Department of Chemistry

This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:07:30 CDT