home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


UNIX Power Tools

UNIX Power ToolsSearch this book
Previous: 17.15 Searching for Files by Permission Chapter 17
Finding Files with find
Next: 17.17 Duplicating a Directory Tree (No Pathnames with find {} Operator)
 

17.16 Searching by Owner and Group

Often you need to look for a file belonging to a certain user or group. This is done with the -user and -group search operators. You often need to combine this with a search for particular permissions. To find all files that are set user ID ( 1.23 ) to root, use:

% 

find . -user root -perm -4000 -print

To find all files that are set group ID ( 1.23 ) to staff , use:

% 

find . -group staff -perm -2000 -print

Instead of using a name or group from /etc/passwd ( 36.3 ) or /etc/group ( 22.13 ) , you can use the UID or GID number ( 38.3 ) :

% 

find . -user 0 -perm -4000 -print


% 

find . -group 10 -perm -2000 -print

Often, when a user leaves a site, his account is deleted, but his files are still on the computer. Some versions of find have -nouser or -nogroup operators to find files with an unknown user or group ID.

- BB


Previous: 17.15 Searching for Files by Permission UNIX Power Tools Next: 17.17 Duplicating a Directory Tree (No Pathnames with find {} Operator)
17.15 Searching for Files by Permission Book Index 17.17 Duplicating a Directory Tree (No Pathnames with find {} Operator)

The UNIX CD Bookshelf Navigation The UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System