Linux – How to make new files automatically belong to group

centoschgrplinuxPHPwebsite

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

Best Answer

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

Related Topic