the unix power tools
源代码在线查看: ch17_16.htm
> > >[Chapter 17] 17.16 Searching by Owner and Group > NAME="DC.title" CONTENT="UNIX Power Tools"> NAME="DC.creator" CONTENT="Jerry Peek, Tim O'Reilly & Mike Loukides"> NAME="DC.publisher" CONTENT="O'Reilly & Associates, Inc."> NAME="DC.date" CONTENT="1998-08-04T21:38:30Z"> NAME="DC.type" CONTENT="Text.Monograph"> NAME="DC.format" CONTENT="text/html" SCHEME="MIME"> NAME="DC.source" CONTENT="1-56592-260-3" SCHEME="ISBN"> NAME="DC.language" CONTENT="en-US"> NAME="generator" CONTENT="Jade 1.1/O'Reilly DocBook 3.0 to HTML 4.0"> REV="made" HREF="mailto:online-books@oreilly.com" TITLE="Online Books Comments"> REL="up" HREF="ch17_01.htm" TITLE="17. Finding Files with find"> REL="prev" HREF="ch17_15.htm" TITLE="17.15 Searching for Files by Permission "> REL="next" HREF="ch17_17.htm" TITLE="17.17 Duplicating a Directory Tree (No Pathnames with find {} Operator)"> > BGCOLOR="#FFFFFF" TEXT="#000000" > CLASS="htmlnav" > > SRC="gifs/smbanner.gif" ALT="UNIX Power Tools" USEMAP="#srchmap" BORDER="0"> > NAME="srchmap" > SHAPE="RECT" COORDS="0,0,466,58" HREF="index.htm" ALT="UNIX Power Tools"> SHAPE="RECT" COORDS="467,0,514,18" HREF="jobjects/fsearch.htm" ALT="Search this book"> > WIDTH="515" BORDER="0" CELLSPACING="0" CELLPADDING="0" > > ALIGN="LEFT" VALIGN="TOP" WIDTH="172" > CLASS="SECT1" HREF="ch17_15.htm" TITLE="17.15 Searching for Files by Permission " > SRC="gifs/txtpreva.gif" SRC="gifs/txtpreva.gif" ALT="Previous: 17.15 Searching for Files by Permission " BORDER="0"> > > ALIGN="CENTER" VALIGN="TOP" WIDTH="171" > > FACE="ARIEL,HELVETICA,HELV,SANSERIF" SIZE="-1" >Chapter 17Finding Files with find > > > ALIGN="RIGHT" VALIGN="TOP" WIDTH="172" > CLASS="SECT1" HREF="ch17_17.htm" TITLE="17.17 Duplicating a Directory Tree (No Pathnames with find {} Operator)" > SRC="gifs/txtnexta.gif" SRC="gifs/txtnexta.gif" ALT="Next: 17.17 Duplicating a Directory Tree (No Pathnames with find {} Operator)" BORDER="0"> > > > > ALIGN="LEFT" WIDTH="515" TITLE="footer"> > CLASS="SECT1" > CLASS="sect1" > CLASS="title" NAME="UPT-ART-7940" >17.16 Searching by Owner and Group > > CLASS="para" > CLASS="indexterm" NAME="AUTOID-19268" > > CLASS="indexterm" NAME="AUTOID-19271" > > CLASS="indexterm" NAME="AUTOID-19274" > > CLASS="indexterm" NAME="AUTOID-19277" > > CLASS="indexterm" NAME="AUTOID-19280" > > CLASS="indexterm" NAME="AUTOID-19283" > > CLASS="indexterm" NAME="AUTOID-19287" > > CLASS="indexterm" NAME="AUTOID-19290" > >Often you need to look for a file belonging to a certain user or group. This is done with the CLASS="emphasis" >-user > and CLASS="emphasis" >-group > search operators. You often need to combine this with a search for particular permissions. To find all files that are CLASS="link" >set user ID ( CLASS="linkend" HREF="ch01_23.htm" TITLE="File Access Permissions " >1.23 >) > to root, use: > CLASS="para" > CLASS="screen" > CLASS="screen" >% CLASS="userinput" > >find . -user root -perm -4000 -print > > > > > CLASS="para" >To find all files that are CLASS="link" >set group ID ( CLASS="linkend" HREF="ch01_23.htm" TITLE="File Access Permissions " >1.23 >) > to CLASS="emphasis" >staff >, use: > CLASS="para" > CLASS="screen" > CLASS="screen" >% CLASS="userinput" > >find . -group staff -perm -2000 -print > > > > > CLASS="para" >Instead of using a name or group from CLASS="link" > CLASS="emphasis" >/etc/passwd > ( CLASS="linkend" HREF="ch36_03.htm" TITLE="Changing the Field Delimiter " >36.3 >) > or CLASS="link" > CLASS="emphasis" >/etc/group > ( CLASS="linkend" HREF="ch22_13.htm" TITLE="Groups and Group Ownership " >22.13 >) >, you can use the CLASS="link" >UID or GID number ( CLASS="linkend" HREF="ch38_03.htm" TITLE="Managing Processes: Overall Concepts " >38.3 >) >: > CLASS="para" > CLASS="screen" > CLASS="screen" >% CLASS="userinput" > >find . -user 0 -perm -4000 -print > > % CLASS="userinput" > >find . -group 10 -perm -2000 -print > > > > > CLASS="para" >Often, when a user leaves a site, his account is deleted, but his files are still on the computer. Some versions of CLASS="emphasis" >find > have CLASS="indexterm" NAME="AUTOID-19317" > > CLASS="indexterm" NAME="AUTOID-19320" > > CLASS="emphasis" >-nouser > or CLASS="emphasis" >-nogroup > operators to find files with an unknown user or group ID. > CLASS="sect1info" > CLASS="SECT1INFO" >- CLASS="authorinitials" >BB > > > > CLASS="htmlnav" > > > ALIGN="LEFT" WIDTH="515" TITLE="footer"> WIDTH="515" BORDER="0" CELLSPACING="0" CELLPADDING="0" > > ALIGN="LEFT" VALIGN="TOP" WIDTH="172" > CLASS="SECT1" HREF="ch17_15.htm" TITLE="17.15 Searching for Files by Permission " > SRC="gifs/txtpreva.gif" SRC="gifs/txtpreva.gif" ALT="Previous: 17.15 Searching for Files by Permission " BORDER="0"> > > ALIGN="CENTER" VALIGN="TOP" WIDTH="171" > CLASS="book" HREF="index.htm" TITLE="UNIX Power Tools" > SRC="gifs/txthome.gif" SRC="gifs/txthome.gif" ALT="UNIX Power Tools" BORDER="0"> > > ALIGN="RIGHT" VALIGN="TOP" WIDTH="172" > CLASS="SECT1" HREF="ch17_17.htm" TITLE="17.17 Duplicating a Directory Tree (No Pathnames with find {} Operator)" > SRC="gifs/txtnexta.gif" SRC="gifs/txtnexta.gif" ALT="Next: 17.17 Duplicating a Directory Tree (No Pathnames with find {} Operator)" BORDER="0"> > > > > ALIGN="LEFT" VALIGN="TOP" WIDTH="172" >17.15 Searching for Files by Permission > ALIGN="CENTER" VALIGN="TOP" WIDTH="171" > CLASS="index" HREF="index/idx_0.htm" TITLE="Book Index" > SRC="gifs/index.gif" SRC="gifs/index.gif" ALT="Book Index" BORDER="0"> > > ALIGN="RIGHT" VALIGN="TOP" WIDTH="172" >17.17 Duplicating a Directory Tree (No Pathnames with find {} Operator) > > > ALIGN="LEFT" WIDTH="515" TITLE="footer"> SRC="gifs/smnavbar.gif" SRC="gifs/smnavbar.gif" USEMAP="#map" BORDER="0" ALT="The UNIX CD Bookshelf Navigation"> NAME="map" > SHAPE="RECT" COORDS="0,0,73,21" HREF="../index.htm" ALT="The UNIX CD Bookshelf"> SHAPE="RECT" COORDS="74,0,163,21" HREF="index.htm" ALT="UNIX Power Tools"> SHAPE="RECT" COORDS="164,0,257,21" HREF="../unixnut/index.htm" ALT="UNIX in a Nutshell"> SHAPE="RECT" COORDS="258,0,321,21" HREF="../vi/index.htm" ALT="Learning the vi Editor"> SHAPE="RECT" COORDS="322,0,378,21" HREF="../sedawk/index.htm" ALT="sed & awk"> SHAPE="RECT" COORDS="379,0,438,21" HREF="../ksh/index.htm" ALT="Learning the Korn Shell"> SHAPE="RECT" COORDS="439,0,514,21" HREF="../lrnunix/index.htm" ALT="Learning the UNIX Operating System"> > > > >