0

Can I use linux groups and file permission to permit multiple people to add modify and delete files into multiple folders and how?

For example on a local machine :

Having Alice and Bob working on foo and bar

Alice and Bob being in foo and bar linux groups foo and bar folders being root proprietary with respecting groups :

id Alice
uid=1000(Alice) gid=1000(Alice) groups=1000(Alice),10(wheel),1002(foo),1003(bar)

id Bob
uid=1001(Bob) gid=1001(Bob) groups=1001(Bob),10(wheel),1002(foo),1003(bar)

ll
drwxrwsr-x 7 root foo 4096 Jan 26 09:09 foo
drwxrwsr-x 7 root bar 4096 Apr 13 09:36 bar

Having Peter that can only work on foo folder and not bar folder.

id Peter
uid=1002(Peter) gid=1004(Peter) groups=1001(Bob),10(wheel),1002(foo)

Is this possible to do it on linux?

I've been using the GUID bit and the sticky bit, but none of them exactly match the need.

Having Alice and Bob access to foo implies to put them on the group foo. Adding foo to their supplementary group does not produce any effect and Alice and Bob cannot access to foo folder.

Alice and Bob cannot be on foo and bar primary group at the same time, that's why I'm asking this question.

6
  • A distinct example with some ls -l output would be of great help.
    – pLumo
    Apr 13, 2021 at 8:50
  • Is there a reason why the work needs to happen in a joint directory tree and not separately in user's home directories? It would be easy to organize this with Git or some similar software.
    – Kusalananda
    Apr 13, 2021 at 8:59
  • @Kusalananda, these directories may host several git repository accessed by ssh. a second question was that I was wondering if pushing data to a git server may do something else that adding data (modify or remove them). But even if Git looks like working as a charm, I would know the answer of this question for my personal culture. Apr 13, 2021 at 9:33
  • If you are accessing Git repositories via SSH, then access could be restricted with the use of SSH keys. Again, no special setup with Unix permissions is required. You need to properly explain what you are doing, because the solution depends on the type of data and the mode of access that is required.
    – Kusalananda
    Apr 13, 2021 at 9:46
  • If I open ssh account, access is restricted for each user to their home folder. If I want them to work together on the same projects, I may then create shared folders, that's why I asked this question. Apr 13, 2021 at 10:55

1 Answer 1

0

I didn't seen any way to permit two user to modify the same files in the same shared folder.

The usual workaround looks like using a version control tool.

In that particular case that's ok because we use GIT here.

But once again an issue spawned : Even if git only adds files to the objects folder (unless you do things we don't know about in the target project of this question), git does it gathering files in objects's subfolders named with the two first character of the commit hash.

We finally found a workaround by create all directories as root preventing their creation by user :

for i in {0..255};do j=$(printf "%02x\n" $i);mkdir -p $j;chmod 2775 $j;done

Done it in objects folder of the bare repo, now, all is ok.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .