Encounter “operation not permitted” error when using find even though terminal has been granted full disk access

macbook promacosterminal

I tried to use find command to find a file named color.cfg (It is a configuration file for latex)
Here is my code:

Yichens-MacBook-Pro:~ apple$ sudo find / -name "color.cfg"
/usr/local/texlive/2020/texmf-dist/tex/latex/graphics-cfg/color.cfg
/usr/local/texlive/2020/texmf-dist/doc/generic/pgf/version-for-dvisvgm/en/color.cfg
find: /Library/Caches/com.apple.aned: Operation not permitted
find: /System/Library/Templates/Data/private/var/db/oah: Operation not permitted
/System/Volumes/Data/usr/local/texlive/2020/texmf-dist/tex/latex/graphics-cfg/color.cfg
/System/Volumes/Data/usr/local/texlive/2020/texmf-dist/doc/generic/pgf/version-for-dvisvgm/en/color.cfg
find: /System/Volumes/Data/.Spotlight-V100: No such file or directory
find: /System/Volumes/Data/net: No such file or directory
find: /System/Volumes/Data/boot: No such file or directory
find: /System/Volumes/Data/.PKInstallSandboxManager-SystemSoftware: No such file or directory
find: /System/Volumes/Data/.adobeTemp: No such file or directory
find: /System/Volumes/Data/Network: No such file or directory
find: /System/Volumes/Data/Library/Caches/com.apple.aned: Operation not permitted
find: /System/Volumes/Data/System/Library/Templates/Data/private/var/db/oah: Operation not permitted
find: /System/Volumes/Data/mnt: No such file or directory
find: /System/Volumes/Data/.fseventsd: No such file or directory
find: /System/Volumes/Data/private/var/networkd/db: Operation not permitted
find: /System/Volumes/Data/private/var/db/appinstalld: Operation not permitted
find: /System/Volumes/Data/private/var/db/fpsd/dvp: Operation not permitted
find: /System/Volumes/Data/private/var/db/installcoordinationd: Operation not permitted
find: /System/Volumes/Data/private/var/db/oah: Operation not permitted
find: /System/Volumes/Data/private/var/db/lockdown: Operation not permitted
find: /System/Volumes/Data/private/var/db/KernelExtensionManagement/Staging: Operation not permitted
find: /System/Volumes/Data/private/var/db/DifferentialPrivacy: Operation not permitted
find: /System/Volumes/Data/private/var/db/MobileIdentityService: Operation not permitted
find: /System/Volumes/Data/private/var/db/searchparty: Operation not permitted
find: /System/Volumes/Data/private/var/db/CoreDuet/Knowledge: Operation not permitted
find: /System/Volumes/Data/private/var/db/ConfigurationProfiles/Store: Operation not permitted
find: /System/Volumes/Data/private/var/folders/ys/nkcxlbwj4qldtphp_278zpbw0000gn/0/SafariFamily: Operation not permitted
find: /System/Volumes/Data/private/var/folders/ys/nkcxlbwj4qldtphp_278zpbw0000gn/0/com.apple.ScreenTimeAgent/Store: Operation not permitted
find: /System/Volumes/Data/private/var/folders/ys/nkcxlbwj4qldtphp_278zpbw0000gn/0/com.apple.lockoutagent: Operation not permitted
find: /System/Volumes/Data/private/var/folders/ys/nkcxlbwj4qldtphp_278zpbw0000gn/0/com.apple.progressd/ClassKit: Operation not permitted
find: /System/Volumes/Data/private/var/folders/ys/nkcxlbwj4qldtphp_278zpbw0000gn/0/com.apple.exchangesync: Operation not permitted
find: /System/Volumes/Data/private/var/folders/ys/nkcxlbwj4qldtphp_278zpbw0000gn/0/com.apple.Safari/SafariFamily: Operation not permitted
find: /System/Volumes/Data/private/var/folders/ys/nkcxlbwj4qldtphp_278zpbw0000gn/0/com.apple.LaunchServices.dv: Operation not permitted
find: /System/Volumes/Data/private/var/folders/ys/nkcxlbwj4qldtphp_278zpbw0000gn/0/dmd: Operation not permitted
find: /System/Volumes/Data/private/var/folders/ys/nkcxlbwj4qldtphp_278zpbw0000gn/0/com.apple.nsurlsessiond: Operation not permitted
find: /System/Volumes/Data/private/var/folders/ys/nkcxlbwj4qldtphp_278zpbw0000gn/0/com.apple.SharedWebCredentials: Operation not permitted
find: /System/Volumes/Data/private/var/folders/ys/nkcxlbwj4qldtphp_278zpbw0000gn/0/com.apple.routined: Operation not permitted
find: /System/Volumes/Data/private/var/folders/ys/nkcxlbwj4qldtphp_278zpbw0000gn/C/com.apple.WebKit.WebContent.Sandbox: Operation not permitted
find: /System/Volumes/Data/private/var/folders/ys/nkcxlbwj4qldtphp_278zpbw0000gn/C/com.apple.QuickLook.thumbnailcache: Operation not permitted
find: /System/Volumes/Data/private/var/folders/ys/nkcxlbwj4qldtphp_278zpbw0000gn/C/com.apple.WebKit.Networking.Sandbox: Operation not permitted
find: /System/Volumes/Data/private/var/folders/ys/nkcxlbwj4qldtphp_278zpbw0000gn/C/com.apple.quicklook.ThumbnailsAgent/com.apple.QuickLook.thumbnailcache: Operation not permitted
find: /System/Volumes/Data/private/var/folders/ys/nkcxlbwj4qldtphp_278zpbw0000gn/C/com.apple.WebKit.GPU.Sandbox: Operation not permitted
find: /System/Volumes/Data/private/var/folders/zz/zyxvpxvq6csfxvn_n00000sm00006d/0: Operation not permitted
find: /System/Volumes/Data/private/var/folders/zz/zyxvpxvq6csfxvn_n00000sm00006d/C: Operation not permitted
find: /System/Volumes/Data/private/var/folders/zz/zyxvpxvq6csfxvn_n00000y800007k/0/com.apple.nsurlsessiond: Operation not permitted
find: /System/Volumes/Data/private/var/folders/zz/zyxvpxvq6csfxvn_n00000z000007r/0/com.apple.nsurlsessiond: Operation not permitted
find: /System/Volumes/Data/private/var/folders/zz/zyxvpxvq6csfxvn_n00000z000007r/0/com.apple.routined: Operation not permitted
find: /System/Volumes/Data/private/var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/0/com.apple.LaunchServices.dv: Operation not permitted
find: /System/Volumes/Data/private/var/protected/trustd/private: Operation not permitted
find: /System/Volumes/Data/.DocumentRevisions-V100: No such file or directory
find: /System/Volumes/Data/dev/fd/3: Not a directory
find: /System/Volumes/Data/dev/fd/4: Not a directory
find: /System/Volumes/Data/dev/fd/6: Not a directory
find: /System/Volumes/Data/.PreviousSystemInformation: No such file or directory
find: /System/Volumes/Data/.TemporaryItems: No such file or directory
find: /System/Volumes/iSCPreboot: No such file or directory
find: /System/DriverKit: No such file or directory
find: /private/var/networkd/db: Operation not permitted
find: /private/var/db/appinstalld: Operation not permitted
find: /private/var/db/fpsd/dvp: Operation not permitted
find: /private/var/db/installcoordinationd: Operation not permitted
find: /private/var/db/oah: Operation not permitted
find: /private/var/db/lockdown: Operation not permitted
find: /private/var/db/KernelExtensionManagement/Staging: Operation not permitted
find: /private/var/db/DifferentialPrivacy: Operation not permitted
find: /private/var/db/MobileIdentityService: Operation not permitted
find: /private/var/db/searchparty: Operation not permitted
find: /private/var/db/CoreDuet/Knowledge: Operation not permitted
find: /private/var/db/ConfigurationProfiles/Store: Operation not permitted
find: /private/var/folders/ys/nkcxlbwj4qldtphp_278zpbw0000gn/0/SafariFamily: Operation not permitted
find: /private/var/folders/ys/nkcxlbwj4qldtphp_278zpbw0000gn/0/com.apple.ScreenTimeAgent/Store: Operation not permitted
find: /private/var/folders/ys/nkcxlbwj4qldtphp_278zpbw0000gn/0/com.apple.lockoutagent: Operation not permitted
find: /private/var/folders/ys/nkcxlbwj4qldtphp_278zpbw0000gn/0/com.apple.progressd/ClassKit: Operation not permitted
find: /private/var/folders/ys/nkcxlbwj4qldtphp_278zpbw0000gn/0/com.apple.exchangesync: Operation not permitted
find: /private/var/folders/ys/nkcxlbwj4qldtphp_278zpbw0000gn/0/com.apple.Safari/SafariFamily: Operation not permitted
find: /private/var/folders/ys/nkcxlbwj4qldtphp_278zpbw0000gn/0/com.apple.LaunchServices.dv: Operation not permitted
find: /private/var/folders/ys/nkcxlbwj4qldtphp_278zpbw0000gn/0/dmd: Operation not permitted
find: /private/var/folders/ys/nkcxlbwj4qldtphp_278zpbw0000gn/0/com.apple.nsurlsessiond: Operation not permitted
find: /private/var/folders/ys/nkcxlbwj4qldtphp_278zpbw0000gn/0/com.apple.SharedWebCredentials: Operation not permitted
find: /private/var/folders/ys/nkcxlbwj4qldtphp_278zpbw0000gn/0/com.apple.routined: Operation not permitted
find: /private/var/folders/ys/nkcxlbwj4qldtphp_278zpbw0000gn/C/com.apple.WebKit.WebContent.Sandbox: Operation not permitted
find: /private/var/folders/ys/nkcxlbwj4qldtphp_278zpbw0000gn/C/com.apple.QuickLook.thumbnailcache: Operation not permitted
find: /private/var/folders/ys/nkcxlbwj4qldtphp_278zpbw0000gn/C/com.apple.WebKit.Networking.Sandbox: Operation not permitted
find: /private/var/folders/ys/nkcxlbwj4qldtphp_278zpbw0000gn/C/com.apple.quicklook.ThumbnailsAgent/com.apple.QuickLook.thumbnailcache: Operation not permitted
find: /private/var/folders/ys/nkcxlbwj4qldtphp_278zpbw0000gn/C/com.apple.WebKit.GPU.Sandbox: Operation not permitted
find: /private/var/folders/zz/zyxvpxvq6csfxvn_n00000sm00006d/0: Operation not permitted
find: /private/var/folders/zz/zyxvpxvq6csfxvn_n00000sm00006d/C: Operation not permitted
find: /private/var/folders/zz/zyxvpxvq6csfxvn_n00000y800007k/0/com.apple.nsurlsessiond: Operation not permitted
find: /private/var/folders/zz/zyxvpxvq6csfxvn_n00000z000007r/0/com.apple.nsurlsessiond: Operation not permitted
find: /private/var/folders/zz/zyxvpxvq6csfxvn_n00000z000007r/0/com.apple.routined: Operation not permitted
find: /private/var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/0/com.apple.LaunchServices.dv: Operation not permitted
find: /private/var/protected/trustd/private: Operation not permitted
find: /dev/fd/3: Not a directory
find: /dev/fd/4: Not a directory
find: /dev/fd/6: Not a directory

As you can see, the screen is clustered with "operation not permitted" error and "Not a directory" error, which makes it impossible for me to search for files that I need.

This solution doesn't work as I have already given the full disk access permission to the terminal.
enter image description here

Best Answer

The directories look system related so it is expected that your user would not have permissions to read the content. Giving your terminal emulator full disk access will not change that, that would be a massive security risk.

There is another solution which works on every unix based and most other OS:

redirect error output

Usually on unixoidal operating systems you can redirect stderr to a file so that it wont clutter your terminals stdout by adding 2> /somefile.

Example:

sudo find / -name "color.cfg" 2> /dev/null

Related Question