I have made some vhosts which resides on my home folder, and i have given the group access to www-data user. This way the project (a web system) renders on the browser.

This is a symfony based project, so that when i run some console commands some files may be created, but unfortunately it will have my user account as the group account. How can i dynamically change the owner (group owner) of that particular directory, so that on creation of every file: its ownership is set as :


1 Answer 1


You can set the setgid sticky bit on the directory to ensure that all new files in the directory will have their group set to the group of the directory.

To do that, run chmod g+s DIRECTORY, where DIRECTORY is the name of your directory.

  • 1
    @kisanme, Give him/her an upvote. ;)
    – A.B.
    Apr 11, 2015 at 15:03
  • 1
    @A.B. i don't have enough reputation to do so. But i awfully wanted to.... :( Apr 11, 2015 at 17:05

You must log in to answer this question.

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