2

对不起,如果我的问题太简单了。我知道如何更改目录“我的目录”的所有者。但是假设我有一个 git 用户在目录中拥有一个文件“myfile”

-rw-r--r--   1 git   staff 9201 somedate myfile

但我想添加一个现有用户,该用户对所有文件目录具有相同级别的所有权。我怎样才能做到这一点 ?

4

2 回答 2

3

Do you mean that you want two users to have the same permissions for all of the contents of a directory?

If so, there are potentially two ways:

  • Add the two users to a group, and give that group suitable access to the directory. You can create a fresh group just for this, if you want.

  • Use ACLs. This depends on your unix: the BSDs tend now to have good support for ACLs, Linuxes somewhat less so (broadly speaking). Do man acl to see what's available. This route can get confusing quite quickly.

The other possibility is to set the directory's sticky bit (see man sticky). This is how the /tmp directory is configured, and it lets multiple users create and own files within a directory, without letting them see others' files. I don't know if that matches what you're looking for, but if it does, it's more straightforward than either of the two suggestions above.

于 2013-04-13T15:46:00.180 回答
1

文件或目录具有:1)和所有者(git在您的情况下);2)一组(staff在你的情况下)和3)其他。在您的情况下,所有者为“rw”权限,该组具有“r”权限,其他人具有“r”权限。

如果您希望每个人都拥有相同的权限,请说“rw”,然后使用:

chmod g+w,o+w myfile

如果您只希望另一个用户拥有与所有者相同的权限,那么您必须将该其他用户放入staff组中。或者,创建另一个组,并将所有其他用户放在该组中。创建组并向该组添加成员取决于您的操作系统。一旦你有了组,你会做:

   chgrp mygrp myfile
   chmod g+w myfile
于 2013-04-13T20:23:03.750 回答