【问题标题】:Does the chmod command not work on Windows in GitBash? [closed]chmod 命令在 GitBash 中的 Windows 上不起作用吗? [关闭]
【发布时间】:2020-03-15 09:31:06
【问题描述】:

我正在模拟类 Unix 环境中的一些命令。我在 Windows 10 上并使用 GitBash 的 shell 运行命令,但 chmod 似乎没有保留文件的权限更改。

zecuse MINGW64 ~ (dev)
$ touch test
zecuse MINGW64 ~ (dev)
$ ls -l test
-rw-r--r-- 1 zecuse 1049089 0 Nov 13 13:30 test
zecuse MINGW64 ~ (dev)
$ chmod -c -r test
mode of 'test' changed from 0644 (rw-r--r--) to 0200 (-w-------)
zecuse MINGW64 ~ (dev)
$ ls -l test
-rw-r--r-- 1 zecuse 1049089 0 Nov 13 13:30 test

Windows 是否会阻止我以这种方式更改文件权限?如果是这样,我是否需要使用 powershell 来修改文件的权限?

【问题讨论】:

    标签: git-bash


    【解决方案1】:

    不,windows文件系统好像不兼容gitbash chmod:https://www.reddit.com/r/git/comments/dss843/chmod_not_working_with_git_bash_in_windows/

    我认为这与 powershell 无关。

    【讨论】:

      【解决方案2】:

      chmod 的等价物是 icacls

      请参考-

      https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/icacls

      How to grant permission to users for a directory using command line in Windows?

      如果是 chmod 0200 - 用户写入权限

      尝试使用 cmd 提示符或 powershell

      icacls test1 /grant User1:(w)

      【讨论】:

      • 这是在 powershell 中运行的吗?在 gitbash icacls test3 /grant zecuse:\(N\) 中运行时,我得到了 Invalid parameter "C:/Program Files/Git/grant"
      • 是的。这应该在 powershell 中运行
      猜你喜欢
      • 1970-01-01
      • 2022-01-25
      • 2012-01-30
      • 1970-01-01
      • 2011-09-23
      • 2013-01-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多