Find Files by Ownership


find -user

In addition to searching for files by name, you can also search for files by owner. Do you want to find the files on the music drive owned by scott? Use find with the -user option, followed by the user name (or the user number, which you can find in /etc/passwd):

$ find . -user scott 


Whoa! There are way too many results! It might be easier to look for files that are not owned by scott. To do so, put a ! in front of the option you wish to reverse:

Note

In order to conserve space, some of the data you'd normally see with ls -l has been removed.


$ find . ! -user scott ./Outsider/Wing/01_-_Dancing_Queen.mp3 $ ls -l ./Outsider/Wing/01_-_Dancing_Queen.mp3 gus music ./Outsider/Wing/01_-_Dancing_Queen.mp3 


Ah... one song by Wing is owned by gus instead of scott. To fix this problem, we need to use chown (covered in Chapter 7, "Ownerships and Permissions"). Keep in mind that you can always use the ! as a NOT operator (which is saying, for example, "find files where the user is not scott").

Note

Ah, Wing. First introduced to the world at large in an episode of South Park, her website can be found at www.wingtunes.com. Wing's version of "Dancing Queen" is highly recommended, as is her rendition of "I Want to Hold Your Hand."




Linux Phrasebook
Linux Phrasebook
ISBN: 0672328380
EAN: 2147483647
Year: 2007
Pages: 288

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net