chmod cannot change group permission on Cygwin

前端 未结 7 1269
孤城傲影
孤城傲影 2020-12-10 02:41

I am using Cygwin and trying to change the group access permission with chmod, e.g.

$ls -l id_rsa
-rwxrwxr-- 1 None 1679 Jun 13 10:16 id_rsa 

$ chmod g= id_         


        
7条回答
  •  悲&欢浪女
    2020-12-10 02:52

    Cygwin doesn't like files to be owned by groups that it doesn't know. Unfortunately, that happens quite often in Cygwin, especially if your PC is in a Windows domain where things keep changing. I also synchronise my files between two PCs, via an external drive, and the uids/gids are different between the different PCs, so this is a source of problems.

    If you do ls -l and see a numeric group id instead of a group name, it means Cygwin doesn't know the gid - i.e. it's not in /etc/group, and Cygwin can't query it from Windows either. You can confirm this by running getent group , where is the numeric group id.

    To fix it, you can either use chgrp to change the group for all affected files/directories, as described in the accepted answer above, or create an entry for the unknown gid in /etc/group, with any unused group name (e.g. Users2).

    After doing this, it may be necessary to close all of your Cygwin windows and then re-open them.

提交回复
热议问题