I spent a few hours yesterday trying to get this done but ran into several problems, and worst of all, I couldn’t find one single post addressing all permission problems associated with allowing several users access to the same directory for read/write operations.
The best way of creating a shared directory is to create a user and group, and then a home directory. Make other users members of the new group and set permission inheritence to propagate to child objects regardless of the user who is creating or uploading the file.
User name is shareowner and group, sharedhome.
Create a user, group and home directory for the new user:
useradd -d /home/shareowner -g sharedhome -m shareowner
The above command creates a user and group as user’s primary group. I wouldn’t create a password for the user if I don’t want the user to actually be able to logon to the server. Once the home directory is created I will add the existing users to the new group:
usermod -G sharedhome existinguser1
usermod -G sharedhome existinguser2
and so on. Note that I use -G and not -g, as I want users to become additional users of the new group. Now we set permissions for the new directory… I make shareowner the owner, and sharedhome the group that owns the directory:
chown -R shareowner:sharedhome /home/sharedhome
Then I use umask and chmod to force all files in /home/sharedhome to inherit permissions from the top directory:
chmod -R g+s /home/sharedhome
That’s it. Now existinguser1 and existinguser2 should have read/write permission to /home/sharedhome directory.