I want to give write access to a folder for many users, but the files and folder they create in it must have their primary group id. For example i create a directory as root and give the permissions for everyone:
Now I create a file as user1 and user2:
I want to have the following permissions:
Code:
root@hostname1:~ # mkdir /test
root@hostname1:~ # chmod 777 /test
root@hostname1:~ # ls -la /test
total 8
drwxrwxrwx 2 root wheel 512 Nov 6 12:53 .
drwxr-xr-x 20 root wheel 1024 Nov 6 12:53 ..
Code:
$ id
uid=1002(user1) gid=1002(user1) groups=1002(user1)
$ touch /test/user1.txt
$ ls -la /test/user1.txt
-rw-r--r-- 1 user1 wheel 0 Nov 6 13:01 /test/user1.txt
Code:
$ id
uid=1003(user2) gid=1003(user2) groups=1003(user2)
$ touch /test/user2.txt
$ ls -la /test/user2.txt
-rw-r--r-- 1 user2 wheel 0 Nov 6 13:03 /test/user2.txt
Is it possible to configure the system that it creates new files and folders with the primary group id of the user creating them?/test/user1.txt having the GID 1002
/test/user2.txt having the GID 1003