0
点赞
收藏
分享

微信扫一扫

unable to execute xxx.sh : Operation not permitted 问题


一、背景

之前在本地创建了 shell 脚本,在 iterm 中 cd 到该目录,可以通过 ​​./xxx.sh​​ 的方式去执行。

今天突然发现报了如下错误:

unable to execute xxx.sh : Operation not permitted

或者

-bash: ./xxx.sh: /usr/bin/env: bad interpreter: Operation not permitted

最近把系统升级为 Monterey 版本,怀疑和系统升级有关系。

unable to execute xxx.sh : Operation not permitted 问题_bash

二、分析思路

​ls -l​​ 查看权限

unable to execute xxx.sh : Operation not permitted 问题_搜索_02

发现有执行权限

使用 ​​ls -l@​​ 来查看附加属性

unable to execute xxx.sh : Operation not permitted 问题_centos_03


搜索里面的几个属性发现一些线索

苹果系统有一个GateKeeper保护机制(自 OSX 10.5 加入)。从互联网上下载来的文件,会被自动打上 com.apple.quarantine 标志,翻译过来就是免疫隔离,系统根据这个附加属性对这个文件作出限制。

三、解决办法

sudo xattr -r -d com.apple.quarantine +目录路径

输入系统密码即可。

unable to execute xxx.sh : Operation not permitted 问题_centos_04

设置完成后 执行 ​​./test.sh​​ 发现可以正常执行

创作不易,如果本文对你有帮助,欢迎点赞、收藏加关注,你的支持和鼓励,是我创作的最大动力。

unable to execute xxx.sh : Operation not permitted 问题_搜索_05


举报

相关推荐

0 条评论