1

I'm searching my system for a folder called Group Containers, and use the command find / type -d -name "Group Containers". The output did include the desired folder, along with over 100 Permission denied results like this:

find: /usr/sbin/authserver: Permission denied
find: /.Spotlight-V100: Operation not permitted
find: /Library/Application Support/Apple/ParentalControls/Users: Permission denied
find: /Library/Application Support/Apple/AssetCache/Data: Permission denied
find: /Library/Application Support/ApplePushService: Permission denied
find: /Library/Application Support/com.apple.TCC: Operation not permitted

I was able to filter out these results by changing the command to find / type -d -name "Group Containers" 2>/dev/null, but I'm curious why these Permission denied results come up in the first place, seeing as none of them seems to contain the Group Containers search term.

Does anyone know why these results are returned?

gkeenley
  • 6,088
  • 8
  • 54
  • 129
  • 3
    This is probably better asked on https://unix.stackexchange.com , but: `find` recursively looks at all the directories under the starting point (`/`, in your case). `/usr/sbin/authserver` is a directory that only root has access to (`ls -l` will show `drwx------`), so `find` issues a warning message when it is unable to read the contents of that directory and/or `chdir` to it. – Mark Plotnick Nov 16 '20 at 16:26
  • I'll post questions like this on unix.stackexchange.com in the future. For your answer, am I understanding correctly that for each of the folders displayed with `Permission denied`, `find` is trying to search for "Group Containers" in that folder, but doesn't have permission, so it displays the folder with `Permission denied`? – gkeenley Nov 16 '20 at 16:33
  • Yes, that's it. You might, rarely, also see errors for *files* rather than folders if a file's containing folder has read access but not execute access. – Mark Plotnick Nov 16 '20 at 16:43
  • Ok thanks, if you want to post that as a reply I'll accept it. – gkeenley Nov 16 '20 at 16:45
  • Does this answer your question? [Linux find command permission denied](https://stackoverflow.com/questions/37493764/linux-find-command-permission-denied) – Léa Gris Nov 16 '20 at 18:13

2 Answers2

2

As you have specified / as the root path to search, with no maxdepth parameter, the find command will search every directory as default. It reports errors as you have seen to inform you and make you aware of the fact that additional entries matching your search criteria may exist in these directories but permissions are stopping them from being searched.

Raman Sailopal
  • 12,320
  • 2
  • 11
  • 18
2

To prevent searching within permission denied paths

find / -type d ! -readable -prune -name "Group Containers"

or

find / -type d -not -readable -prune -name "Group Containers"

-not -readable -prune: Discards (prune) not readable paths.

See other answer to Linux find command permission denied

Léa Gris
  • 17,497
  • 4
  • 32
  • 41