2
1
I've read countless articles on the topic and searched through every question and answer I could find without any luck. I'm slowly going mad so I'm turning to you guys since I know the answer to my question is most likely simple.
On my web server, I have two users and two groups. The users need to read and write to the same area. Not a single folder, but a complex network of folders.
>> groups user_1
popuser psaserv psacln
>> groups user_2
psacln popuser psaserv
These aren't real users so they don't have .bashrc files. When each of the users creates a directory, the permissions look exactly how I'd expect:
drwxr-xr-x 2 user_1 popuser 4096 Apr 30 20:47 folder_1
drwxr-xr-x 2 user_2 psacln 4096 Apr 30 20:49 folder_2
But once one of the two users creates the folder, the other is unable to write any files to it.
If I chmod 777, then of course they can both write.
cat /etc/group
popuser:x:31:user_1,psaserv,user_2
psacln:x:505:user_2,user_1,psaserv
Also unusual is that when a file is written into the group, the permissions seem very restrictive:
-rw-r--r-- 1 user_2 psacln 0 Apr 30 21:15 some_file.ext
Although maybe that's expected.
Anyway, to sum up and clarify my two part question:
1) How can I make both users access files and folders from each other, given their group differences?
2) How can I set the default permissions on new files so they inherit the folder permissions?
(2) I've tried adding umask 022 into my ~/.bashrc file for my root user, but it didn't do anything. I'm unsure where to put that for these "users" who don't have home directories.
Sorry, I know questions like this can feel redundant for you Linux user experts. Searching is difficult when I don't even know what I'm looking for.
Thanks so much, as always.
[I'm on centOS]
1Look at setting the SGID bit on a directory, which'll force all new subdirs created in it to take on the same GID as the container. – None – 2012-05-01T04:47:58.543
Thanks for the suggestion, Marc. I just spent about an hour trying to figure this out, but I still feel so lost. On my root most directory of the structure that both users/groups need to write to, I did this: chmod -R g+rxws,u+rxws,o+rxs root_dir And that gave me these permissions on everything inside: drwxrwsrwx. Immediately after doing that, everything works, until one of the users creates a new directory. Then, the new directories have these permissions: drwx--S---, which is no good. The other group can't write into that directory anymore. What am I doing wrong? – Ryan Martin – 2012-05-01T17:44:26.683