change permission of directory and all its sub-directories/files recursively

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP








up vote
1
down vote

favorite












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)



  1. create a new virtual host (i have completed this)

  2. create a new directory /var/www/example (i have completed this)

  3. created new group and user with the same name(as i wanted to mimic the same as www-data user and group.)

  4. 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)


  5. 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







share|improve this question






















  • Check this: superuser.com/questions/381416/…
    – Sebastian Stark
    May 4 at 11:21














up vote
1
down vote

favorite












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)



  1. create a new virtual host (i have completed this)

  2. create a new directory /var/www/example (i have completed this)

  3. created new group and user with the same name(as i wanted to mimic the same as www-data user and group.)

  4. 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)


  5. 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







share|improve this question






















  • Check this: superuser.com/questions/381416/…
    – Sebastian Stark
    May 4 at 11:21












up vote
1
down vote

favorite









up vote
1
down vote

favorite











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)



  1. create a new virtual host (i have completed this)

  2. create a new directory /var/www/example (i have completed this)

  3. created new group and user with the same name(as i wanted to mimic the same as www-data user and group.)

  4. 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)


  5. 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







share|improve this question














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)



  1. create a new virtual host (i have completed this)

  2. create a new directory /var/www/example (i have completed this)

  3. created new group and user with the same name(as i wanted to mimic the same as www-data user and group.)

  4. 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)


  5. 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









share|improve this question













share|improve this question




share|improve this question








edited May 4 at 11:11









Byte Commander

59k26158265




59k26158265










asked May 4 at 11:07









Deez Nutz

206




206











  • Check this: superuser.com/questions/381416/…
    – Sebastian Stark
    May 4 at 11:21
















  • Check this: superuser.com/questions/381416/…
    – Sebastian Stark
    May 4 at 11:21















Check this: superuser.com/questions/381416/…
– Sebastian Stark
May 4 at 11:21




Check this: superuser.com/questions/381416/…
– Sebastian Stark
May 4 at 11:21















active

oldest

votes











Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "89"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);








 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1031931%2fchange-permission-of-directory-and-all-its-sub-directories-files-recursively%23new-answer', 'question_page');

);

Post as a guest



































active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes










 

draft saved


draft discarded


























 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1031931%2fchange-permission-of-directory-and-all-its-sub-directories-files-recursively%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

Which professions warranted travel in Medieval times?

How do so many people here on Academia.SE, and in general, afford lavish higher education programs?

Trouble downloading packages list due to a “Hash sum mismatch” error