SUMMARY: CHGRP large # of files

From: Edward Huang (ehuang@atmel.com)
Date: Mon Aug 07 2000 - 15:29:49 CDT


thanks for quick responses!

people suggested CHGRP -R (I'm talking about MANY directories and the files in
those directories are may be members of several different groups) or swap the
definitions in the GROUP file (Sorry but we have to use the official ID NUMBER
as dictated by SAP/ORACLE)

Thanks to the following persons who gave scripts to accomplish the task, using
FIND and shell utilities plus one perl:

---------------------------------------------------------------------------------

From: James Cannon <James.Cannon@calmit.unl.edu>

> (ie, SAPSYS is 101 when it should be 102 and DBA is 102 when should be 101)
>
> over 11,000 files in many directories need to be fixed
>
> Does anyone have any suggestions how to do this??? (besides typing CHGRP
> one by one) Are there scripts or utilities to do this automatically?
>
Well the first thing that comes to mind isn't exactly slick but it would get
the job done...

# find /directory -group 101 -print > dba.txt
# find /directory -group 102 -print > sapsys.txt
# for i in `cat dba.txt`; do chgrp dba $i; done
# for i in `cat sapsys.txt`; do chgrp sapsys $i; done

and your done. It will take a while but it should work. If you get any
better methods, more power to you. Please summarize and let us know.
Cheers,
--James

---------------------------------------------------------------------------------

From: Dave Paper <cerberus@aol.net>

On Mon, 7 Aug 2000, Edward Huang wrote:

> Hi,
>
> Sun installed a new server and their S.E. mixed up the Group IDs
> for SAPSYS and DBA

Make Sun come and fix it. :)

> (ie, SAPSYS is 101 when it should be 102 and DBA is 102 when should be 101)
>
> over 11,000 files in many directories need to be fixed
>
> Does anyone have any suggestions how to do this??? (besides typing CHGRP
> one by one) Are there scripts or utilities to do this automatically?

find . -user 101 -print > /tmp/101.list
find . -user 102 -print > /tmp/102.list

(pick your favorite shell here, I use tcsh)

foreach z (`cat /tmp/101.list`)
chgrp 102 $z
end

foreach z (`cat /tmp/102.list`)
chgrp 101 $z
end

-dave

--
Dave Paper              AOL Database Operations         cerberus@aol.net
MCSE = Must Consult Someone Experienced  --Jay
It's no accident "user" is a 4 letter word --KV

---------------------------------------------------------------------------------

From: "Chris O'Malley" <Chriso@staff-abuzz.com>

How about:

If you're using local /etc/group files, why not just make the switch 'official' and swap them in the group file?

or:

find / -group 101 -exec chgrp 103 {} \; # or some other unused group find / -group 102 -exec chgrp 101 {} \; find / -group 103 -exec chgrp 102 {} \;

you get the idea..

---------------------------------------------------------------------------------

I'd do a little smoke and mirrors action

Create a user named something other than sapsys and dba....such as tempuser

1) find / -user dba -exec chown tempuser {} \ 2) find / -user sapsys -exec chown dba {} \; 3) find / -user tempuser -exec chown sapsys {} \

.....or something like that

- Ray rsaddler@cccis.com

---------------------------------------------------------------------------------

From: "Keith A. Clay" <Keith.Clay@clayk.acu.edu>

> Hi, > > Sun installed a new server and their S.E. mixed up the Group IDs > for SAPSYS and DBA > > (ie, SAPSYS is 101 when it should be 102 and DBA is 102 when should be 101) > > over 11,000 files in many directories need to be fixed > > Does anyone have any suggestions how to do this??? (besides typing CHGRP > one by one) Are there scripts or utilities to do this automatically? > > thanks very much, > --Ed

if you change the group file, the changes should occur on each file.

If you still need to change files after that, you can run find like this:

find <starting_dir> -group <group_name> -exec chgrp <new_group_name> {} \;

or find <starting_dir> -gid <group_number> -exec chgrp <new_group_name> {} \;

or if you want to change them all to one group then chgrp -R <new_group_name> <directory where you want to start>

keith ---------------------------------------- Keith A. Clay, Keith.Clay@acu.edu Abilene Christian University System Administrator, Academic Computing UNIX and Web Administration 290 Center for Teaching Excellence (915) 674-2187 (915) 674-2834 (fax) ________________________________________ "...continue to walk like that One walked..."

---------------------------------------------------------------------------------

From: "Seth Rothenberg" <SROTHENB@montefiore.org>

Ed, It sounds like you need a way to break up the files into smaller groups.

One way is to pipe the output of ls to the split command, then use chgrp `cat xaa` chgrp `cat xab` etc.

Another way is to use find, which will walk the whole directory tree one record at a time.....

find . -exec chgrp 102 { } \;

the "\;" is the end-of-line for the exec parameter to find.....

Seth

---------------------------------------------------------------------------------

From: Andre Koopal <andre@NL.UU.NET>

On Mon, Aug 07, 2000 at 12:56:56PM -0700, Edward Huang wrote: > Hi, > > Sun installed a new server and their S.E. mixed up the Group IDs > for SAPSYS and DBA > > (ie, SAPSYS is 101 when it should be 102 and DBA is 102 when should be 101) > > over 11,000 files in many directories need to be fixed > > Does anyone have any suggestions how to do this??? (besides typing CHGRP > one by one) Are there scripts or utilities to do this automatically?

You can find all files with group 101 by doing:

find /basedir -group 101 -print

Doing this twice gives you a list of files to change, and from there you can work it out yourself I guess.

Regards,

Andre Koopal UUNET > > thanks very much, > --Ed

---------------------------------------------------------------------------------

From: "John T. Douglass" <john.douglass@anlw.anl.gov> > > Hi, > > Sun installed a new server and their S.E. mixed up the Group IDs > for SAPSYS and DBA > > (ie, SAPSYS is 101 when it should be 102 and DBA is 102 when should be 101) > > over 11,000 files in many directories need to be fixed > > Does anyone have any suggestions how to do this??? (besides typing CHGRP > one by one) Are there scripts or utilities to do this automatically? > > thanks very much, > --Ed >

One possiblity that comes to mind is find and xargs. You could create a temporary new group and use something like:

# change all the files with gid 101 to tmpgrp find / -group 101 | xargs chgrp tmpgrp

# change all files with gid 102 to 101 find / -group 102 | xargs chgrp 101

# change all the tmpgrp files to gid 102 find / -group tmpgrp | xargs chgrp 102

Just a thought...

-- John -- John T. Douglass Phone: 208 533 7992 Argonne National Laboratory-West Email: john.douglass@anl.gov

---------------------------------------------------------------------------------

From: Richard Bond <rbond@mbt.washington.edu>

http://www.sial.org

-follow links to code-

modefix.pl is in there somewhere.

- Richard Bond (rbond@mbt.washington.edu (206) 605-3561 System Administrator K-351, Health Sciences Center Department of Molecular Biotechnology Box 357730 University of Washington Seattle, WA 98195

S U BEFORE POSTING please READ the FAQ located at N ftp://ftp.cs.toronto.edu/pub/jdd/sun-managers/faq . and the list POLICY statement located at M ftp://ftp.cs.toronto.edu/pub/jdd/sun-managers/policy A To submit questions/summaries to this list send your email message to: N sun-managers@ececs.uc.edu A To unsubscribe from this list please send an email message to: G majordomo@sunmanagers.ececs.uc.edu E and in the BODY type: R unsubscribe sun-managers S Or . unsubscribe sun-managers original@subscription.address L To view an archive of this list please visit: I http://www.latech.edu/sunman.html S T



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