2

I'm working on simulating some commands in a Unix-like environment. I'm on Windows 10 and using GitBash's shell to run commands but chmod doesn't appear to keep the permission changes on a file.

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

Does Windows prevent me from changing file permissions in this way? If so, do I need to use powershell to modify a file's permissions?

js2010
  • 17,785
  • 4
  • 45
  • 50
zecuse
  • 51
  • 1
  • 6

2 Answers2

0

an equivalent of chmod would be icacls

Please refer -

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?

In case of chmod 0200 - user write permission

Try using cmd prompt or powershell

icacls test1 /grant User1:(w)

0

No, it doesn't seem like the windows file system is compatible with gitbash chmod: https://www.reddit.com/r/git/comments/dss843/chmod_not_working_with_git_bash_in_windows/

I don't think this is relevant to powershell.

js2010
  • 17,785
  • 4
  • 45
  • 50