Since you say it's on an Ubuntu server, I'm going to assume you are using a command line interface (not graphical desktop). To change permissions for a single directory, but only for a limited number of users, you would need to change the group that that directory belongs to. Every file (and directory) belongs to one user, and one group. Let's say the group name is "superusers" (it could be anything).
- First off, create a new group by using the command
addgroup superusers. You need to be root for this, or run with the sudo-command.
- Then you would change the group that the home directory of User C (/home/c) belongs to. This is done by the command
chown -R :superusers. The -R flag makes sure every file in the directory gets owned by the superusers-group.
- Now you need to add user A and user B as members of that group. This is done by running one command for each user. Run
sudo usermod -G superusers -a B. Naturally B is the name of the user you want to add to the group. The -a flag appends the group superusers to the list of groups user B is a member of. This is to make sure we don't mess something up. Do this once more for user A.
If you've followed these steps correctly and you had root privileges all along, you should now have the desired effect you're looking for. User A and B should be able to write and read to the home directory of user C.
In some cases, files may be readable or writable only by the owner. This is too much to explain here, but you can read up on "file permissions" and the
chmod-command if you want to study further. A nice guide is available here. What it means is that some individual files can't be read or written to by the group - only by the owner. To change this, you would use the command
chmod g+rw <file>, or
chmod g+rw -R /home/C to change the permissions of every file in the home directory of user C. This adds read and write permissions to the group that the file is owned by, in this case group "superusers", as per step 2 in the guide.
As an addition, I'll say that this is not a recommended way of doing things. Normally you would create a third directory and give all three users read-write access to that directory.
I don't know of a way to make sure every file created in that directory will have the same user- and group ownership. You can add default permissions by using the
umask-command, but that won't change the default ownership. I actually doubt this is doable, and actually against the *nix standards, but it would be great if anyone could correct me on that.