chmod WSL (Bash) 不起作用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/46610256/
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 WSL (Bash) doesn't work
提问by joe5
Running bash on windows 10, the simple syntax below works when I SSH to my webserver, but not when I exit out and am on my local machine. It doesn't give me an error, but I can see permissions are unchanged. I have to checked that I am set up as an administrator on my computer. Is this an error or is this just a consequence of the local operating system being windows? IF the later, it makes me question the value of using bash on windows if common operations such as this won't work.
在 Windows 10 上运行 bash,下面的简单语法在我通过 SSH 连接到我的网络服务器时有效,但在我退出并在我的本地机器上时无效。它没有给我一个错误,但我可以看到权限没有改变。我必须检查我是否已在计算机上设置为管理员。这是一个错误还是只是本地操作系统是 windows 的结果?如果是后者,如果像这样的常见操作不起作用,这让我质疑在 Windows 上使用 bash 的价值。
$chmod 644 filename
回答by Chao
Amade's answer is correct, but please note, the cmd only take effect in session scope. If you exit current bash, you'll lose your setting.
Amade 的回答是正确的,但请注意,cmd 仅在会话范围内生效。如果您退出当前的 bash,您将丢失您的设置。
To fix this, you need to edit /etc/wsl.conf. and put below config in.
要解决此问题,您需要编辑 /etc/wsl.conf。并放入下面的配置。
[automount]
enabled = true
options = "metadata"
Ref:
参考:
回答by Amade
回答by hko
Both Amades and Chaos answers are correct.
But it only works for local drives not for mapped network drives. Z: is one of my network drives. Same operation on /mnt/c/Users/xxx/
works fine.
Amades 和 Chaos 的答案都是正确的。但它仅适用于本地驱动器,不适用于映射的网络驱动器。Z:是我的网络驱动器之一。相同的操作/mnt/c/Users/xxx/
工作正常。
$sudo mount -t drvfs Z: /mnt/z -o metadata
$touch test
$chmod +w test
chmod: changing permissions of 'test': Operation not permitted
This is a known issue, see drvfs: metadata (chmod\chown) possible for mounted SMB drives?
这是一个已知问题,请参阅drvfs: metadata (chmod\chown) possible for mounted SMB drive?