0

I need to find the name of the file which is owned by the root user, and has global read, write, and execute permissions. Lastly, it contains the following contents "immerse"

this is my command line on the terminal:

find -type f -user root -perm 777 | xargs grep =l "immerse"

However it is returning me a lot of results with permission denied. Please advice if my input is correct, thanks

  • 1
    Note that -perm 777 would find files that have those permissions exactly (only 0777, not 1777, 2777... 7777). You may prefer -perm -777 for files that have at least those permissions. – Stéphane Chazelas Aug 24 '18 at 10:52
  • Hi and welcome to U&L ! - This may be out of scope (probably), but if you operate on a network with Access Control lists (be it Attribute Based or otherwise) and in particular NFS, -perm -777 will gleefully ignore some AC based privileges. – Cbhihe Aug 25 '18 at 9:26
2

For starters, I think this might be a typo: grep =l

Did you mean -l, --files-with-matches?

       -l, --files-with-matches
              Suppress  normal output; instead print the name of
              each input file from which output  would  normally
              have  been printed.  The scanning will stop on the
              first match.

And here is a working example of how I would construct the find, with slightly different parameters:

$ find . -type f -user maulinglawns -perm 644 -exec grep -l 'file_metadata' {} +
./rust/fsmtime/src/main.rs


it is returning me a lot of results with permission denied

Are you running as root?

  • Thank you (again!) @Stéphane Chazelas, a.k.a ”hawkeye” ;-) – maulinglawns Aug 24 '18 at 10:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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