macos 在 OS X 中更改目录的所有权
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10865795/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Changing Ownership of a directory in OS X
提问by Graeme
I've installed homebrew, and am trying to change the write permissisons for the /usr/local/include directory.
我已经安装了自制软件,并且正在尝试更改 /usr/local/include 目录的写入权限。
When I run 'brew doctor', I get this error message:
当我运行 'brew doctor' 时,我收到以下错误消息:
Error: The /usr/local directory is not writable. Even if this directory was writable when you installed Homebrew, other software may change permissions on this directory. Some versions of the "InstantOn" component of Airfoil are known to do this.
You should probably change the ownership and permissions of /usr/local back to your user account.
错误:/usr/local 目录不可写。即使在您安装 Homebrew 时此目录是可写的,其他软件也可能会更改此目录的权限。已知某些版本的 Airfoil 的“InstantOn”组件可以执行此操作。
您可能应该将 /usr/local 的所有权和权限更改回您的用户帐户。
I tried doing that with chown, but I'm pretty new at this and don't think I was running it correctly. I ran:
我尝试用 chown 来做这件事,但我对此很陌生,并且认为我没有正确运行它。我跑了:
chown myusername /usr/local/include
I didn't get any error message, but when I run brew doctor it says I still lack permission to write to /usr/local/include.
我没有收到任何错误消息,但是当我运行 brew doctor 时,它说我仍然缺乏写入 /usr/local/include 的权限。
Any help would be greatly appreciated!
任何帮助将不胜感激!
Edit:
编辑:
I'm getting an "operation not permitted" error.
我收到“不允许的操作”错误。
cd /usr
cd /usr
chown myusername local
chown myusername local
chown: local: Operation not permitted
chown: local: 不允许操作
采纳答案by lanzz
On my system, /usr/local
is owned by root:admin
and is rwxrwxr-x
. My user is a member of the admin
group, thus has write permissions. I haven't messed with ownership and permissions there, and my Homebrew installation is not complaining, so I assume my setup fits its requirements.
在我的系统上,/usr/local
由root:admin
和拥有rwxrwxr-x
。我的用户是该admin
组的成员,因此具有写入权限。我没有在那里弄乱所有权和权限,而且我的 Homebrew 安装没有抱怨,所以我假设我的设置符合它的要求。
Check the ownership of your /usr/local
; if it is owned by group admin
, check if your non-adminsitrator account is a member of that group.
检查您的所有权/usr/local
;如果它归组所有admin
,请检查您的非管理员帐户是否是该组的成员。
回答by clawsthatroll
Simple solution that worked for me:
对我有用的简单解决方案:
- click on your background to go to finder
- click on go and go to folder /usr
- right click on local and do get info
- unlock the lock at the bottom
- click + sign and add your user to the list and give read/write privileges
- click on the gear sign at the bottom and choose apply to enclosed items to recurse under that directory and assign privileges too all directories beneath it.
- 点击你的背景去寻找
- 单击 go 并转到文件夹 /usr
- 右键单击本地并获取信息
- 解锁底部的锁
- 单击 + 号并将您的用户添加到列表中并授予读/写权限
- 单击底部的齿轮标志并选择应用于封闭项目以在该目录下递归并为其下的所有目录分配权限。
type brew doctor
from command prompt to test. My result:
键入brew doctor
从命令提示来测试。我的结果:
Your system is ready to brew.
您的系统已准备好冲泡。
回答by Vadim Klyuzner
You should use: sudo chown username folder
你应该使用: sudo chown username folder
回答by ePi272314
Be careful with the change of ownership
小心所有权变更
Do not try to change ownership for /usr/
or recursively for /usr/local/
if you are not getting the same error posted in the original question.
You could screw up your system or weakness its security.
如果您没有收到原始问题中发布的相同错误,请不要尝试更改所有权/usr/
或递归更改/usr/local/
。
您可能会搞砸您的系统或削弱其安全性。
Some users can receive with homebrew permission errors that could be solved without changing the ownership of the whole /usr/
or /usr/local/
directories.
一些用户可能会收到自制程序权限错误,这些错误可以在不更改整个/usr/
或/usr/local/
目录的所有权的情况下解决。
According to my experience, in most cases, it is just enough to restore the ownership for /usr/local/Cellar
:
根据我的经验,在大多数情况下,只需恢复以下对象的所有权即可/usr/local/Cellar
:
sudo chown -R "$USER" /usr/local/Cellar/
Alternatively, if you have a not standard installation
或者,如果您没有标准安装
sudo chown -R "$USER" "$(brew --prefix)/Cellar"
回答by MrWatson
Exactly this problem has just started occuring on my MacBook.
正是这个问题刚刚开始出现在我的 MacBook 上。
The owner of /usr/local is:
/usr/local 的所有者是:
drwxr-xr-x 24 root wheel 768 Apr 9 17:25 local
I am unable to change the permissions and add myself via Finder - I get a "you don't have the necessary permission" error.
我无法更改权限并通过 Finder 添加自己 - 我收到“您没有必要的权限”错误。
Is this maybe due to security changes in mac os? (I have 10.13.6)
这可能是由于 mac os 的安全性变化吗?(我有 10.13.6)
回答by Martin Pr??a
You can try use command ls -l
. With this command you will see list of files in current directory with some useful information, like who is owner of this file. So you will see if chown
worked out. I believe that chown
is a right command for changing ownership.
您可以尝试使用命令ls -l
。使用此命令,您将看到当前目录中的文件列表,其中包含一些有用的信息,例如此文件的所有者。所以你会看到是否chown
成功。我相信这chown
是改变所有权的正确命令。