I have search around but can't find the correct answer.
How do I change the permission of a directory and all its sub-directories/files then also when a user creates a file or directory this must also follow the same permissions set at the beginning.
Basically this is what i want to do:
Keep in mind I am running a Ubuntu Server 16.04.3 with 2 virtual hosts (so 2 separate IP's used)
- create a new virtual host (i have completed this)
- create a new directory
/var/www/example(i have completed this)
- created new group and user with the same name(as i wanted to mimic the same as www-data user and group.)
change ownership of directory: -- used command:
sudo chown -R user:group /var/www/example(this change the owner to my desired owner and group owner)
set permissions of this directory to 775 -- used command:
sudo chmod -R 775 /var/www/example(this changed the permissions)
after all of these done i am still able to use a user to create a file which is good as this user is in the group i created but the thing is that the permissions are all wrong and the file owner is also wrong. (the user i used is also part of another group that is used on the other virtual host).
Please guide me to a solution. thanks