5

I am trying to find all non readable 'ACL-wise' in a subdirectory owned by another user www-data, and that on a 'FreeBSD' server. This server prevents me from using the command find . ! -readable

How could I find all the non-readable (by the current user) files in a directory?

7

You can always do:

find . -exec sh -c '
  for file do
    [ -r "$file" ] || printf "%s\n" "$file"
  done' sh {} +

To list the files you don't have read permission for.

Note that for symlinks, that checks the target of the symlink.

It also obviously won't report files in directories you don't have read permission to (which may contain files you have read access to (provided you have search access to the directory) and/or files you don't have read access to).

On FreeBSD, you should also be able to do:

find . -print0 | perl -Mfiletest=access -l -0ne 'print unless -r'

Or

sudo find . -print0 | perl -Mfiletest=access -l -0ne 'print unless -r'

To also list the files in the directories you don't have read access to.

(neither sudo, -print0 nor perl are specified by POSIX).

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.