I am attempting to configure the file permissions that are set on directories and files when they are created by a specific user/group, but seem to be having a bit of an issue.

I have tried setting the following:

chmod 2770 /path/to/directory
chmod g+rwxs /path/to/directory

However when I create a new directory within this directory for example


deletemeplease will have permissions drwxr-sr-x

Any files created within /path/to/directory/ have permissions rw-r--r--

I have also tried setting ACLs for the directory such as below:

setfacl -dm u::rwx,g::rwx,o::r /path/to/directory

When setting ACL, permissions of created files and directories become rw-rw-r-- which is getting closer, but the execute bit is still not being set.

Is there a step I'm missing here?


The linked answer is only explaining the difference between umask and chmod. My issue is that after setting permissions they are not taking place.

When a new directory or file is created I am expecting the permissions to be set to rwxrwxr--. Howevever when a new directory is created the directory has permissions rwxr-sr--. When a new file is created the permissions are rw-rw-r--. Then if a new directory is created and contains files, the files within the newly created directory have permissions rw-r--r-- which is very strange.

I just discovered that when creating files and directories within the terminal, that permissions are being applied as expected (minus the execute bit for files). The strange behaviour described above is happening when directories/files are being created via rsync from a script that's being executed. The script is being executed via www-data user, which is the directory user and group for the directory which has the acls applied, so should they not be applied when rsync runs?

The script which is running rsync is using executing the following command:

rsync -rltgoDzvO /path/for/files/to/sync /path/to/directory
  • Please be specific then: what exact permissions do you expect/need for a new file? directory? – Kamil Maciorowski Oct 22 '17 at 17:09
  • @KamilMaciorowski question has been updated. If further information is required, please let me know and I can elaborate further. – nullReference Oct 22 '17 at 17:16
  • If the problem is related tto rsync, stating the rsync options would be useful. – xenoid Oct 22 '17 at 19:38
  • @xenoid questions updated to include rsync command options – nullReference Oct 22 '17 at 23:33

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.