1

I've been trying to set up a shared folder to store some files for a group of people, for example /home/project. At the moment, I've done the following:

Created a group, let's call it "members", and added two users, user1 and user2.

When I run cat /etc/group I get the following return:

members:x:1005:user1,user2

Which at least seems to be correct. Then I create the directory and addign permissions following, to be honest, some internet guides.

mkdir /home/project
sudo chown -R root.members /home/project
sudo chmod 775 /home/project
sudo chmod 2775 /home/project

All of that seems to go fine, but when I create a test text file as user2, user1 can read that file, but doesn't have write permissions. What am I doing wrong?

  • 1
    @Christopher 0002, aka u=rwx,g=rwx,o=rx – Fomite Apr 9 '18 at 20:30
  • is the machine running selinux? if so, it may be blocking the set permissions. – thebtm Apr 9 '18 at 20:32
  • 1
    @thebtm Looks like it: SELinux status: enabled SELinuxfs mount: /sys/fs/selinux SELinux root directory: /etc/selinux Loaded policy name: targeted Current mode: enforcing Mode from config file: enforcing Policy MLS status: enabled Policy deny_unknown status: allowed Max kernel policy version: 28 – Fomite Apr 9 '18 at 20:34
  • How do you create the file? Are the permissions correct if you use touch file or echo foo >file? – Hauke Laging Apr 9 '18 at 20:42
  • Just created a simple text document, "test.txt" in nano and saved it. Both touch and echo return "Permission denied" on user2 – Fomite Apr 9 '18 at 20:44
1

Sometimes it's the simple things that we look over when dealing with technical issues. Don't we all do it from time to time? Group membership is acquired when the user logs out and back in again.

2

Your problem is not the permissions of the folder but those of newly created objects. These permissions are determined with two mechanisms:

  1. umask (always)
  2. default ACL (if used)

The umask determines which permissions are blocked for new objects, and its default value is 022, blocking write permissions for both the group and the others. You have to set this value accordingly on each login, e.g. to

umask 002

If you use ACL then you can configure the group permissions for new objects:

setfacl -m d:g::rwx /home/project
  • 1
    Note that my umask is already 0002, which as I understand it should allow group write permissions. – Fomite Apr 9 '18 at 20:37
  • Also just ran getfacl on the directory. It says the owner is root, the group is members, flags are -s-, user and group are both rwx. On the file itself, owner is user1, group is members, and both user and group are rw- – Fomite Apr 9 '18 at 20:46
  • @Fomite I guess you have a shell open somewhere for both users. Run id in those shells. Does it show members as a group? – Hauke Laging Apr 9 '18 at 20:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.