3

I have used chgrp for the 'logs' and 'cache' directories, and chmod 770, so both the linux user asigned to that site (used to execute scripts from the command-line), and the user 'apache' can read/write log and cache files (because both users belong to the group of that site).

The problem is that when one of them creates a file, the other one is not able to write or delete it. The file is being created as owned by its creator, but not belonging to the group. I thought using chgrp in the parent directory was the solution.

Any ideas?

PS: I'm on Centos 5.5, and PHP 5.3

1 Answer 1

8

chmoding a directory setgid (g+s) will make all files created within it inherit group ownership.

4
  • 1
    +1, You will may also want to adjust the umask of the users, or services writing into that folder so group members have write access.
    – Zoredache
    Mar 10, 2011 at 1:35
  • It worked, thanks. But is there a way to make all the dirs and files created have 770 permission? My scripts creates both dirs and files Mar 10, 2011 at 2:09
  • Permissions are related to the umask of the creating process. Mar 10, 2011 at 2:10
  • You can also do this, albeit less portably, using POSIX ACLs. I'm fuzzy on the specifics since I rarely use them, but you can man setfacl for details. Mar 10, 2011 at 3:11

You must log in to answer this question.

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