Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Msys shell command to change the attributes of a file

Please let me know a MSYS shell command that can be used for changing the attributes of a file. When I ran a command as ls -l I got the following :

-rw-r--r-- 1 lenovo Admin .....m4sugar.m4

I want to provide full access rights.

Any help is highly appreciated.

Thanks

like image 493
eddie Avatar asked Oct 08 '22 15:10

eddie


1 Answers

@cdhowie is right; this is a bug of msys tracked there -> http://sourceforge.net/tracker/?func=detail&atid=102435&aid=3071537&group_id=2435

It cannot do anything more useful than it already does, unless it fakes it in the POSIX emulation, as Cygwin does. However, what Cygwin does is mostly irrelevant; since MSYS was forked from Cygwin-1.3, most of that faking was deliberately disabled -- it isn't an objective of MSYS, to provide faked POSIX features to the extent supported by Cygwin. If you want Cygwin's behaviour, and MSYS doesn't retain it sufficiently for your needs, then you should use Cygwin.

MSYS is designed to better integrate with the native MS-Windows features supported by MinGW. In this native MS-Windows environment, there is no file system attribute which can mark a file as executable -- that is indicated by magic byte sequences within the file's data space, (and usually also qualified by a file name extension to match). There is no way MSYS chmod can safely modify that, without risk of file corruption, other than by more completely embracing Cygwin's emulation. However, that is diametrically opposed to the MSYS Project objectives -- it just ain't going to happen.

@kbulgrien gives the good approach to change the permissions:

  • cacls: http://ss64.com/nt/cacls.html, or
  • icacls: http://ss64.com/nt/icacls.html

Note: icacls is the new version of cacls correcting several issues but seems to be not present in Windows XP.

You can use either of the following commands to give full access rights to Everyone:

  • cacls "$file_path" //E //P Everyone:F
  • icacls "$file_path" //grant Everyone:F

Note that ls -l in Msys won't display accurate information on real ACLs after the usage of cacls or icacls.

like image 119
Jean-Francois T. Avatar answered Oct 11 '22 02:10

Jean-Francois T.