Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

What could be a command to find all files owned by "abc" user, I guess that can be extended to finding all files with group 'def'.

e.g.

if I got result (ls -l) such as one shown below

-rwxrw-r--   1 apache web      1981 2009-01-22 08:10 unsubscribe.php

then I would like to find all files owned by apache or group web

Thanks!

share|improve this question

migrated from stackoverflow.com Feb 16 '12 at 3:20

This question came from our site for professional and enthusiast programmers.

5 Answers 5

up vote 1 down vote accepted

The find command has options for both. See the find(1) man page for more details.

share|improve this answer
    
thnx. so can I print the result in say ls -l format? –  Jaspreet Chahal Feb 16 '12 at 3:24
    
Absolutely. See the -printf or -ls predicates. –  Ignacio Vazquez-Abrams Feb 16 '12 at 3:25
    
thanks! I will explore it more. –  Jaspreet Chahal Feb 16 '12 at 3:28

The direct answer to your questions:

find /path -type f  \( -user apache -o group web \) -exec ls -l {}; \

The find manpage is very much less than enlightening. IMO.

share|improve this answer

find /home/ -user <username> -group <groupname>

and lots of other search criteria.

share|improve this answer
    
worked like charm. thnx –  Jaspreet Chahal Feb 16 '12 at 3:28

You want find(1) there. It has a whole language on the command line to let you specify what to list based on, including uid, username, gid, and group by name.

share|improve this answer

Use the find program

find path -group group_name
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.