macos - 当 "Operation not permitted"和 `sudo` 不起作用时,如何在 macOS 上避免 `bypass`

标签 macos file-io sudo

在 macOS (High Sierra) 上,当我尝试在路径中列出文件时

/private/var/db/ConfigurationProfiles/Store

我收到错误“Operation not permitted”。使用 sudo并没有更好,甚至使用 bypass helper 不会改变任何东西:
sudo /System/Library/Extensions/TMSafetyNet.kext/Contents/Helpers/bypass ls -l /private/var/db/ConfigurationProfiles/Store

也给出“Operation not permitted”。如何列出/访问路径 /private/var/db/ConfigurationProfiles/Store 下的文件?

附加信息:

通过 ls -al /private/var/db/ConfigurationProfiles 获得的封闭目录列表显示:
drwxr-xr-x   5 root  wheel   160 13 Apr  2018 .
drwxr-xr-x  85 root  wheel  2720 28 Sep 06:27 ..
drwxr-xr-x@  4 root  wheel   128 16 Dec  2017 Settings
drwx------   3 root  wheel    96  1 Oct 21:56 Setup
ls: Store: Operation not permitted

始终如一,但很奇怪 Store无法列出。执行 ls 时都会发生这种情况作为当前用户并通过 sudo .

最佳答案

最可能的原因是 system integrity protection (SIP) - csrutil是命令行实用程序。您需要禁用它才能查看目录。

  • 要查看您的状态,您需要:
  • csrutil status
  • 要禁用它(通常是 想法):
  • csrutil disable (然后您可能需要重新启动)。
  • 要启用它(完成后应该重新打开):
  • csrutil enable

    关于macos - 当 "Operation not permitted"和 `sudo` 不起作用时,如何在 macOS 上避免 `bypass`,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58100326/

    相关文章:

    linux - Collectd 无法读取 Ansible 发送的配置文件

    javascript - 对于文件夹输入,Reactjs 不接受 "webkitdirectory directory"作为输入的属性

    javascript - fs.stat和fs.readFileSync之间的Node.js错误处理相关性

    java - Java 中的方法在某个位置创建文件,必要时创建目录?

    Python - 将文件移动到 Ubuntu 中的根目录

    swift - 不确定的进度指示器没有动画

    python - MacOS 10.8.4 安装 lxml 失败

    macos - Mac 操作系统 X : load average

    bash - Shell 脚本 - Sudo 权限随时间丢失

    java - 如何使用 Java 程序在 Linux 服务器中使用给定用户 ID 的密码执行 sudo 命令?