macos mac 上的 chmod/chown 不工作
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5273258/
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
chmod/chown on mac not working
提问by user3111525
My java command is not working, and I think it is related to permission. I have tried chmod/chown to change the permission but it does not have any affect. When I start the java application with sudo it works. Any idea?
我的java命令不起作用,我认为这与权限有关。我曾尝试 chmod/chown 更改权限,但没有任何影响。当我使用 sudo 启动 java 应用程序时,它可以工作。任何的想法?
iMac:~/ java -version
java(347) malloc: *** error for object 0x10009357c: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Abort trap
iMac:~/ sudo java -version
java version "1.6.0_24"
Java(TM) SE Runtime Environment (build 1.6.0_24-b07-334-10M3326)
Java HotSpot(TM) 64-Bit Server VM (build 19.1-b02-334, mixed mode)
iMac:~/ which java
/usr/bin/java
iMac:~/ sudo chmod 777 /usr/bin/java
iMac:~/ sudo ls -l /usr/bin/java
lrwxrwx--- 1 root wheel 74 Mar 11 10:26 /usr/bin/java -> /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java
iMac:~/
In fact, I notice now that the flash player stopped working as well. What can be wrong? I only restarted computer installed itunes update with Apple Software Update.
事实上,我现在注意到 Flash 播放器也停止工作了。有什么问题?我只用 Apple 软件更新重新启动了安装了 iTunes 更新的计算机。
采纳答案by user3111525
Use Disk Utility to repair permissions.
使用磁盘工具修复权限。
回答by Pierz
Whilst not entirely relevant to the questioner's text but a related answer to actual question title - as in chmod not working on Mac OSX.
虽然与提问者的文本不完全相关,但与实际问题标题相关的答案 - 如 chmod 不适用于 Mac OSX。
With certain files you may run into: [sudo] chmod: Operation Not Permitted. This indicates another problem which is down to the OSX/BSD flagssystem functionality. Any file can have these flags set using the chflagstool, and viewed using ls -lO
yourfile (on osx) ls -lo
yourfile (on BSD). The one that causes this particular error is the 'immutable' flag. Which can be unset using (prefixing it with sudo as necessary):
对于某些文件,您可能会遇到: [sudo] chmod: Operation Not Permitted。这表明另一个问题归结于 OSX/BSD标志系统功能。任何文件都可以使用chflags工具设置这些标志,并使用ls -lO
yourfile(在 osx 上)ls -lo
yourfile(在 BSD 上)查看。导致此特定错误的原因是“不可变”标志。可以使用(根据需要使用 sudo 前缀)取消设置:
chflags nouchg yourfile
回答by Qiau
When you run "ls -l /usr/bin/java" you are only viewing the permissions of the link.
当您运行“ls -l /usr/bin/java”时,您只能查看链接的权限。
If you want to see the "real" permissions, add L to the options, i.e. "ls -lL /usr/bin/java".
如果要查看“真实”权限,请在选项中添加 L,即“ls -lL /usr/bin/java”。
Same thing when you run chmod, then you change the permissions of the real file. If you want to change permissions of the link, add -h to chmod.
运行 chmod 时也是如此,然后更改真实文件的权限。如果要更改链接的权限,请在 chmod 中添加 -h。
Good luck!
祝你好运!