尽管终端已被授予完全磁盘访问权限,使用查找时仍会遇到“操作不允许”错误

尽管终端已被授予完全磁盘访问权限,使用查找时仍会遇到“操作不允许”错误

我尝试使用 find 命令来查找名为 color.cfg 的文件(它是 latex 的配置文件) 这是我的代码:

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

如您所见,屏幕上充斥着“操作不允许”错误和“不是目录”错误,这使我无法搜索所需的文件。

此解决方案无效因为我已经授予终端完全磁盘访问权限。 在此处输入图片描述

答案1

这些目录看起来与系统相关,因此您的用户可能没有权限读取内容。授予终端仿真器完全磁盘访问权限不会改变这一点,否则会造成巨大的安全风险。

还有另一种解决方案,适用于每个基于 UNIX 的操作系统和大多数其他操作系统:

重定向错误输出

通常在unixoidal操作系统上你可以重定向标准错误到一个文件中,这样它就不会通过添加而弄乱你的终端标准输出2> /somefile

例子:

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

相关内容