即使終端機已被授予完全磁碟存取權限,使用 find 時也會遇到「不允許操作」錯誤

即使終端機已被授予完全磁碟存取權限,使用 find 時也會遇到「不允許操作」錯誤

我嘗試使用 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

正如您所看到的,螢幕上聚集著“不允許操作”錯誤和“不是目錄”錯誤,這使得我無法搜尋我需要的文件。

這個解決方案不起作用因為我已經授予終端完整的磁碟存取權限。 在此輸入影像描述

答案1

這些目錄看起來與系統相關,因此預計您的使用者沒有讀取內容的權限。為您的終端模擬器提供完整的磁碟存取權限不會改變這一點,這將是一個巨大的安全風險。

還有另一種解決方案適用於每個基於 UNIX 的作業系統和大多數其他作業系統:

重定向錯誤輸出

通常在 unixoid 作業系統上你可以重定向標準錯誤到文件中,這樣就不會通過添加2> /somefile.

例子:

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

相關內容