I have a ext4 partition and I've set the group owner for all subdirectors to mygroup:
# chgrp -R mygroup /mount/abc
# chmod -R g+swrx /mount/abc
My user is part of that group. Inside that partition is a folder who is owned by user 'nobody' and now by the group 'mygroup'. My user is part of 'mygroup'. Here's an ls -l:
myuser@host:/mount/abc/folder$ ls -l
drwxr-sr-x 2 nobody mygroup 4096 Apr 25 12:08 ./
drwxrwsrwx 6 nobody mygroup 4096 Apr 24 07:57 ../
-rw-r-xr-- 1 otheruser mygroup 159539 Apr 23 23:44 test.png*
myuser@host:/mount/abc/folder$ groups myuser
myuser : mygroup {... a list of other groups also...}
myuser@host:/mount/abc/folder$ rm test.png
rm: remove write-protected regular file ‘test.png’? y
rm: cannot remove ‘test.png’: Permission denied
myuser@host:/mount/abc/folder$ touch test.txt
touch: cannot touch ‘test.txt’: Permission denied
Note that I cannot delete nor create a file that is owned by a group that my user is a part of.
I guess I don't fully understand how groups work. I thought if you were part of a group then you inherit the permissions of that group. Am I doing something wrong?
Thanks