即使在sudo中也无法在/usr/bin中创建符号链接 [英] Cannot create a symlink inside of /usr/bin even as sudo

查看:943
本文介绍了即使在sudo中也无法在/usr/bin中创建符号链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试在/usr/bin文件夹中对二进制文件进行符号链接时,出现操作不允许错误:

When I try to symlink a binary in my /usr/bin folder, I get an Operation not permitted error:

 sudo ln -s /usr/bin/python2.7 /usr/bin/python2
ln: /usr/bin/python2: Operation not permitted

即使是sudo,我也会收到此错误.

Even as sudo, I get this error.

推荐答案

为什么我不能符号链接到/usr/bin?

El Capitan的新系统完整性保护功能可防止对OS X的几个核心部分进行更改,包括/usr/的大部分内容,即使是根用户也是如此.

Why can't I symlink into /usr/bin?

El Capitan's new System Integrity Protection feature prevents changes to several core parts of OS X, including most of /usr/, even by root.

本地自定义项(例如您所做的工作)属于/usr/local.路径/usr/local/bin在默认情况下不存在,但是您可以创建它并在其中放置自定义二进制文件(和符号链接):

Local customizations, such as what you're doing, belong in /usr/local instead. The path /usr/local/bin doesn't exist by default, but you can create it and put custom binaries (and symlinks) in it:

sudo mkdir -p /usr/local/bin
sudo ln -s /usr/bin/python2.7 /usr/local/bin/python2

请注意,虽然/usr/local/bin在默认情况下不存在,但它在默认的PATH中为 ,因此,一旦创建它,​​便会在其中搜索命令.

Note that while /usr/local/bin doesn't exist by default, it is in the default PATH, so as soon as you create it, it'll be searched for commands.

也可以禁用系统完整性保护,但是通常最好将其保留并在更合适的位置进行自定义.有关Apple Stack Exchange的问题的更多详细信息,请参见:什么队长中的无根功能是真的吗?.

It's also possible to disable System Integrity Protection, but it's generally best to leave it on and do customization in more appropriate locations. An Apple Stack Exchange question has more details on this: What is the Rootless Feature in El-Captain, really?.

这篇关于即使在sudo中也无法在/usr/bin中创建符号链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆