Mac OSX使用 sudo 甚至直接使用 root 账号操作仍提示无权限

在 Mac 上, 通过 root 权限去执行命令时, 仍然提示 “Operation not permitted” ,或者去编辑文件时仍然提示 “E45: ‘readonly’ option is set (add ! to override)” , 这是新版本的 Mac OSX 系统增加了 SIP(System Integrity Protection) 特性导致的。SIP 特性顾名思义就是对操作系统完整性的保护。

可以在终端运行 “crsutil status” 命令来查看 SIP 特性是何种状态 :

[yihuaiyuan@/]$ csrutil status
System Integrity Protection status: enabled.

如果是 enabled 状态,表示开启 SIP 特性,默认是开启的。 可以通过 “crsutil disable” 命令关闭:

[yihuaiyuan@/]$ csrutil disable
csrutil: failed to modify system integrity configuration. This tool needs to be executed from the Recovery OS.

根据提示可知,“csrutil disable” 命令不能直接被执行, 只能在 Recovery OS 状态下执行.

接下来重启电脑, 按住 “Command + R” 进入Recovery OS ,然后找到 “实用工具->终端” , 打开终端执行此命令。
image

执行成功会返回 Successfully,并提示需要重启电脑生效

-bash-3.2# csrutil
usage: csrutil <command>
Modify the System Integrity Protection configuration. All configuration changes apply to the entire machine.
Available commands:

    clear
        Clear the existing configuration.
    disable
        Disable the protection on the machine. Only available in Recovery OS.
    enable
        Enable the protection on the machine. Only available in Recovery OS.
    status
        Display the current configuration.

    netboot
        add <address>
            Insert a new IPv4 address in the list of allowed NetBoot sources.
        list
            Print the list of allowed NetBoot sources.
        remove <address>
            Remove an IPv4 address from the list of allowed NetBoot sources.
            
-bash-3.2# crsutil disable
Successfully disabled System Integrity Protection. Please restart the machine for the changes to take effect.
-bash-3.2# 

重启之后再查看 SIP 状态已关闭:

[yihuaiyuan@/]$ csrutil status
System Integrity Protection status: disabled.

之前没有权限的操作就可以操作了, 为了避免以后手抖误操作破坏系统, 可以在本次执行完之后再通过上述方法开启 SIP 。

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
enable-hidpi-osx 是一个用于在 macOS 上启用高分辨率显示的工具。使用该工具可以提高显示效果并增加显示器的清晰度。 以下是在 macOS使用 enable-hidpi-osx 的步骤: 1. 打开终端应用程序。你可以在“应用程序”文件夹中找到它。 2. 在终端中输入以下命令并按下回车键:git clone https://github.com/syscl/Enable-HiDPI-OSX.git 这将从 GitHub 上克隆 enable-hidpi-osx 工具的存储库。 3. 克隆完成后,在终端中切换到克隆存储库的目录。例如,如果存储库位于用户主目录下的“Downloads”文件夹中,则可以使用以下命令进行切换: cd ~/Downloads/Enable-HiDPI-OSX 4. 确保你具有足够的权限来运行脚本。如果需要,可以使用以下命令为脚本添加执行权限: chmod +x enable-hidpi.sh 5. 运行 enable-hidpi-osx 工具。可以使用以下命令运行脚本: ./enable-hidpi.sh 6. 脚本运行后,你将看到一个交互式菜单,列出了当前可用的 HiDPI 选项。选择你希望启用的 HiDPI 模式。 7. 选择完毕后,脚本将自动应用所选的 HiDPI 模式。你可能需要重新启动你的 MacBook 或重新连接你的显示器,以使更改生效。 8. 一旦重新启动或重新连接显示器后,新的 HiDPI 模式将生效,并且你应该会看到更好的显示效果。 这就是使用 enable-hidpi-osx 的简单步骤。请注意, enable-hidpi-osx 工具可能需要在不同版本的 macOS 上进行适当配置和使用。因此,在使用之前,请确保阅读工具存储库中的文档,并确认与你的 macOS 版本兼容。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值