1848261 Members
9301 Online
104022 Solutions
New Discussion

Find by GID (13)

 
SOLVED
Go to solution
Tonya Underwood
Regular Advisor

Find by GID (13)

I had two dba entries in my group file causing issues. I need to find all files on my server owned by GID 13 (I've removed the dup entry) and chgrp to dba (the correct GID 130).

drwxrwxrwx 2 autosys sys 8192 Apr 28 03:14 Autolog
drwxr-xr-x 2 psa 13 96 Nov 21 09:24 DBA
drwxr-xr-x 2 psa sys 96 Nov 21 09:24 EBR
drwxrwxr-x 2 psa 13 96 Nov 21 09:24 SAP
drwxr-xr-x 2 root sys 96 Nov 21 09:24 UX


I've tried find / -group 13 -xdev -exec ll {} \; just to see if my syntax is correct but it isn't even close.

Can show how to pick out that GID 13 which no longer exists in group file?
9 REPLIES 9
Ivan Krastev
Honored Contributor

Re: Find by GID (13)

Create temporary group (dba1) with GID 13.
Find all files:

find / -group dba1 -xdev -exec ll{} \;

After that change group ownership to 130 and delete group dba1.


regards,
ivan
Pete Randall
Outstanding Contributor

Re: Find by GID (13)

Tonya,

I'm just guessing because the man page confuses me. It says "True if the file belongs to the group gname. If gname is numeric and does not appear in the /etc/group file, it is taken as a group ID."

Unable to interpret that particular phrasing, I would suggest creating an entry for GID 13 that names some fictitious group and then searching on the group name.


Pete

Pete
Tonya Underwood
Regular Advisor

Re: Find by GID (13)

Hmmm... I see... creating a temp entry works... but I think that the man page is wrong. It is misleading at best.

Thanks,
Tonya
James R. Ferguson
Acclaimed Contributor

Re: Find by GID (13)

Hi:

# find /path -xdev -group 13 -exec chgrp dba {} \+

Regards!

...JRF...
A. Clay Stephenson
Acclaimed Contributor

Re: Find by GID (13)

There is nothing wrong with your find command although it is possible that you are not executing the "ll" that you think you are.

Do a "type ll" to make sure that it is the command you want and not an alias or use ls -l

find / -group 13 -xdev -exec ls -l {}\;

should do just what you want and the lack of a corresponding group entry shouldn't matter.

Of course, if all you want to do to list those files then

find / -group 13 -xdev > /tmp/mylist
If it ain't broke, I can fix that.
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: Find by GID (13)

You should also note that a very useful find option is -nogroup.
If it ain't broke, I can fix that.
Tonya Underwood
Regular Advisor

Re: Find by GID (13)

nice... I may actually try a mess up with that. THANKS!
john korterman
Honored Contributor

Re: Find by GID (13)

Hi Tonya,

I would suggest skipping the -xdev option. Your find command starts in the / directory and the -xdev option prevents you from crossing mount points, i.e. you will never enter other file systems than root - and the other filesystems are probably where the interesting files are located.

regards,
John K.
it would be nice if you always got a second chance
Tonya Underwood
Regular Advisor

Re: Find by GID (13)

SEE ABOVE.