The function chmod
is implemented in Cygwin but does not fully match access rights in Windows. This appears in the following change log: https://cygwin.com/cygwin-ug-net/ov-new1.7.html
Since 1.7.34, chmod does not always affect the POSIX permission mask as returned by stat(2) or printed by ls(1), due to the improved POSIX ACL handling. However, that's still far from perfect, so, as a temporary workaround, [...]
The implementation of chmod
in Msys is not working, as mentioned in the following bug report: https://sourceforge.net/p/mingw/bugs/1475/
This question is asking how to provide full access rights to a file in Msys.
How can I change the rights of a file to respectively "read-only" and "write-only" in Msys/Cygwin?
Thanks
You can use the commands provided by windows: cacls
and icacls
More information on these commands:
cacls
: http://ss64.com/nt/cacls.html or technet.microsoft.comicacls
: http://ss64.com/nt/icacls.html or technet.microsoft.comIt is now recommended to use icacls
to change permissions easily:
icacls "<file_path>" /grant:r Everyone:R
icacls "<file_path>" /grant:r Everyone:W
icacls "<file_path>" /grant Everyone:F
icacls "<file_path>" /deny Everyone:F
Note: the option :r
make the new Permissions to replace previously granted explicit permissions
If you want to hide the output of the command (details about "processed file xxx" and "Successfully processed ... Failed processing ..."), then you can redirect the standard output to "null" as such:
icacls ... 1>/dev/null
icacls ... 1>null
If you want to keep a compatibility with Windows XP, you will have to use the older calcs
instead by typing 2 lines:
Read-Only with cacls
$ cacls "<file_path>" //E //P Everyone:N 1>/dev/null
$ cacls "<file_path>" //E //G Everyone:R 1>/dev/null
Write-Only with cacls
$ cacls "$file_path" //E //P Everyone:N 1>/dev/null
$ cacls "$file_path" //E //G Everyone:W 1>/dev/null
Notes:
:r
in icacls
).