我尝试使用 find 命令查找名为 color.cfg 的文件(它是乳胶的配置文件)这是我的代码:
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
如您所见,屏幕上出现“不允许操作”错误和“不是目录”错误,这使我无法搜索我需要的文件。
此解决方案不起作用,因为我已经为终端授予了完整的磁盘访问权限。
目录看起来与系统相关,因此预计您的用户将无权读取内容。为您的终端仿真器提供全盘访问权限不会改变这一点,这将是一个巨大的安全风险。
还有另一种解决方案适用于每个基于 unix 的操作系统和大多数其他操作系统:
重定向错误输出
通常在 unixoidal 操作系统上,您可以将stderr重定向到一个文件,这样它就不会通过添加
2> /somefile
.例子:
sudo find / -name "color.cfg" 2> /dev/null