1

I want all the newly created or moved files in a directory to inherit the permissions from the parent directory.

For that I did:

chown -R myuser:myuser /home/directory/
chmod -R 2774 /home/directory/
chmod g+s /home/directory/

So all the files inside that directory have the correct group, but not the correct permissions: 0644. Is there a way to keep that 2774 permissions for all files so the group has access to write/change files ?

1 Answer 1

1

Normally, the UMASK is used to for the permissions. The default UMASK is normally 0022 (these are the bits that are removed from the permission). You could change the UMASK to 0002. You can enlarge the permissions system-wide or just for a single user. The UMASK is linked to the creation, not to the filesystem.

If you want the filesystem to determine the permissions, you should probably use ACLs. Personally, I'm not a fan of those (because of manageability), but

setfacl -Rm g:somegroup:rwX /home/directory 

should do what you want.

Third alternative is a cronjob that sets the permissions every minute, but I would no go there.

4
  • This does set the rw permissions for the group when I execute the command, but if I create another file, the file again has 0644 permissions.
    – Dakado
    Jan 29, 2021 at 14:27
  • I changed to command to: setfacl -d -R -m group:mygroup:rwx /home/directory and it works just fine, thank you!
    – Dakado
    Jan 29, 2021 at 14:30
  • Just follow-up question: is this setting permanent ? So if I set this to the folder, even after reboot, this setting will persist?
    – Dakado
    Jan 29, 2021 at 14:36
  • ACLs will be stored on the filesystem, so it will survive a boot. Jan 29, 2021 at 15:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .