Find the answer to your Linux question:
Results 1 to 4 of 4
Hi, I'm going through the exercises in Practical Guide to Linux Commands, Editors, and Shell Programming. One of them consists of using the find command to find all files you ...
  1. #1
    Just Joined!
    Join Date
    Dec 2009
    Posts
    4

    using the find command to find all files you have read access to

    Hi, I'm going through the exercises in Practical Guide to Linux Commands, Editors, and Shell Programming. One of them consists of using the find command to find all files you have read access to. At first I thought I could use something like -perm /o=r. But I also need to return stuff where the owner has read permission, and I am the owner of the file, or stuff where the group has read permission, and I am in the group. How do I do that? Thanks.

  2. #2
    Just Joined! AsusDave's Avatar
    Join Date
    Dec 2009
    Posts
    2
    What about the -readable option?
    From the man page

    -readable
    Matches files which are readable. This takes into account
    access control lists and other permissions artefacts which the
    -perm test ignores. This test makes use of the access(2) system
    call, and so can be fooled by NFS servers which do UID mapping
    (or root-squashing), since many systems implement access(2) in
    the client’s kernel and so cannot make use of the UID mapping
    information held on the server.

  3. #3
    Just Joined!
    Join Date
    Dec 2009
    Posts
    4
    That would work, except that when I look at my find man page, i don't see that option. I'm running Fedora core. Is there another version of find?

  4. #4
    drl
    drl is online now
    Linux Engineer drl's Avatar
    Join Date
    Apr 2006
    Location
    Saint Paul, MN, USA / CentOS, Debian, Solaris, SuSE
    Posts
    1,117
    Hi.

    This seems to work in Fedora 12:
    Code:
    #!/usr/bin/env bash
    
    # @(#) s1	Demonstrate "-readable" find option, Fedora 12.
    
    echo
    set +o nounset
    LC_ALL=C ; LANG=C ; export LC_ALL LANG
    echo "Environment: LC_ALL = $LC_ALL, LANG = $LANG"
    echo "(Versions displayed with local utility \"version\")"
    version >/dev/null 2>&1 && version "=o" $(_eat $0 $1) find
    set -o nounset
    
    echo
    echo " Results:"
    find .. -readable -type d
    
    exit 0
    producing:
    Code:
    % ./s1
    
    Environment: LC_ALL = C, LANG = C
    (Versions displayed with local utility "version")
    OS, ker|rel, machine: Linux, 2.6.31.6-166.fc12.i686.PAE, i686
    Distribution        : Fedora release 12 (Constantine)
    GNU bash 4.0.35
    find (GNU findutils) 4.4.2
    
     Results:
    ..
    ../find-readable
    ../collect-for-new-box
    Best wishes ... cheers, drl
    Welcome - get the most out of the forum by reading forum basics and guidelines: click here.
    90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
    We look forward to helping you with the challenge of the other 10%.
    ( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...