multiple owner of same folder












2















I have changed owner of /var/www/html folder to www-data,. Now I want to grunt ownership to ubuntu too.



How can I do that. I don't know which group they belong to.
I login to ssh by using ubuntu username and my FTP also working with ubuntu, but now due to this change I am facing permission issue when editing file by ftp.










share|improve this question























  • Can you try sudo usermod -a -G www-data ubuntu and check ?

    – Rooney
    Dec 1 '17 at 12:50













  • askubuntu.com/questions/46331/…

    – Panther
    Dec 1 '17 at 15:41
















2















I have changed owner of /var/www/html folder to www-data,. Now I want to grunt ownership to ubuntu too.



How can I do that. I don't know which group they belong to.
I login to ssh by using ubuntu username and my FTP also working with ubuntu, but now due to this change I am facing permission issue when editing file by ftp.










share|improve this question























  • Can you try sudo usermod -a -G www-data ubuntu and check ?

    – Rooney
    Dec 1 '17 at 12:50













  • askubuntu.com/questions/46331/…

    – Panther
    Dec 1 '17 at 15:41














2












2








2


1






I have changed owner of /var/www/html folder to www-data,. Now I want to grunt ownership to ubuntu too.



How can I do that. I don't know which group they belong to.
I login to ssh by using ubuntu username and my FTP also working with ubuntu, but now due to this change I am facing permission issue when editing file by ftp.










share|improve this question














I have changed owner of /var/www/html folder to www-data,. Now I want to grunt ownership to ubuntu too.



How can I do that. I don't know which group they belong to.
I login to ssh by using ubuntu username and my FTP also working with ubuntu, but now due to this change I am facing permission issue when editing file by ftp.







16.04 aws






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Dec 1 '17 at 12:37









urfusionurfusion

1137




1137













  • Can you try sudo usermod -a -G www-data ubuntu and check ?

    – Rooney
    Dec 1 '17 at 12:50













  • askubuntu.com/questions/46331/…

    – Panther
    Dec 1 '17 at 15:41



















  • Can you try sudo usermod -a -G www-data ubuntu and check ?

    – Rooney
    Dec 1 '17 at 12:50













  • askubuntu.com/questions/46331/…

    – Panther
    Dec 1 '17 at 15:41

















Can you try sudo usermod -a -G www-data ubuntu and check ?

– Rooney
Dec 1 '17 at 12:50







Can you try sudo usermod -a -G www-data ubuntu and check ?

– Rooney
Dec 1 '17 at 12:50















askubuntu.com/questions/46331/…

– Panther
Dec 1 '17 at 15:41





askubuntu.com/questions/46331/…

– Panther
Dec 1 '17 at 15:41










1 Answer
1






active

oldest

votes


















4














Solution 1



Easiest way if only that one user ubuntu and www-data need access would be



sudo chown ubuntu:www-data <path/to/file or directory>


this gives ownership to the user ubuntu but still keeps the ownership for the group www-data.



So you control what ubuntu can do by



sudo chmod u<+|- permission> <path/to/file or directory>


and you control what www-data can do by



sudo chmod g<+|- permission> <path/to/file or directory>


or simply use complete permission masks (see example below).





Example:

User ubuntu shall be able to read(r), write(w), execute(e)
www-data shall be able read(r), execute(e) but not write(w)
other users shall be able to do none of those



sudo chmod u+rwx <path/to/file or directory>
sudo chmod g-w+rx <path/to/file or directory>
sudo chmod o-rwx <path/to/file or directory>


or using a permission masks (helpful generator)



sudo chmod 750 <path/to/file or directory>




Also interresting for your case might be the -R parameter for both commands, applying ownership and permissions recursively on the content of a folder.



For more information about options and parameters see
man chown and
man chmod







Solution 2



I would rather NOT add a user to a system functional user's group as suggested in the comments like



sudo usermod -a -G www-data ubuntu an


as this is a really dirty way of granting a user permissions because he could also fuck up things...



Instead if you want you could add a completely new group using groupadd (see man groupadd)



groupadd <group name>


add all users who shall have the perissions on the file(s) to this group



sudo usermod -a -G <group name> ubuntu
sudo usermod -a -G <group name> www-data


and now set the ownership of the file(s) to this group



sudo chgrp <group name> <path/to/file or directory>


than you set the permissions as described before but this time only for the

group (read(r), write(w), execute(e))



sudo chmod g+rwx <path/to/file or directory>
sudo chmod u-rwx <path/to/file or directory>
sudo chmod o-rwx <path/to/file or directory>


or using the mask



sudo chmod 070 <path/to/file or directory>


Note that using this solution you lose the control over the different permissions for ubuntu and www-data.






share|improve this answer


























  • you need to add the directory name in the last in your first command, right ?

    – Rooney
    Dec 1 '17 at 12:57











  • yes ofcourse .. I just thought if the user states he already changed the ownership he should know how to use chown ;)

    – derHugo
    Dec 1 '17 at 12:58











  • @T.Todua I mentioned it under Solution 1: Also interresting for your case might be the -R parameter.... was that not clear enough? I don't think that one of the two solutions is better or worse .. it depends on the use case which one fits better actually

    – derHugo
    Jan 8 at 20:56











  • dont take it, it was just my thought, ok. btw, can you mention two words about, why www-data shouldnt have write permision?

    – T.Todua
    Jan 8 at 20:57






  • 1





    I have four: It was an example. I only used it to show how the permission flags work. Ofcourse there might be use cases where e.g. the server should be able to write a file as well :)

    – derHugo
    Jan 8 at 21:01











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',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
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%2f982123%2fmultiple-owner-of-same-folder%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









4














Solution 1



Easiest way if only that one user ubuntu and www-data need access would be



sudo chown ubuntu:www-data <path/to/file or directory>


this gives ownership to the user ubuntu but still keeps the ownership for the group www-data.



So you control what ubuntu can do by



sudo chmod u<+|- permission> <path/to/file or directory>


and you control what www-data can do by



sudo chmod g<+|- permission> <path/to/file or directory>


or simply use complete permission masks (see example below).





Example:

User ubuntu shall be able to read(r), write(w), execute(e)
www-data shall be able read(r), execute(e) but not write(w)
other users shall be able to do none of those



sudo chmod u+rwx <path/to/file or directory>
sudo chmod g-w+rx <path/to/file or directory>
sudo chmod o-rwx <path/to/file or directory>


or using a permission masks (helpful generator)



sudo chmod 750 <path/to/file or directory>




Also interresting for your case might be the -R parameter for both commands, applying ownership and permissions recursively on the content of a folder.



For more information about options and parameters see
man chown and
man chmod







Solution 2



I would rather NOT add a user to a system functional user's group as suggested in the comments like



sudo usermod -a -G www-data ubuntu an


as this is a really dirty way of granting a user permissions because he could also fuck up things...



Instead if you want you could add a completely new group using groupadd (see man groupadd)



groupadd <group name>


add all users who shall have the perissions on the file(s) to this group



sudo usermod -a -G <group name> ubuntu
sudo usermod -a -G <group name> www-data


and now set the ownership of the file(s) to this group



sudo chgrp <group name> <path/to/file or directory>


than you set the permissions as described before but this time only for the

group (read(r), write(w), execute(e))



sudo chmod g+rwx <path/to/file or directory>
sudo chmod u-rwx <path/to/file or directory>
sudo chmod o-rwx <path/to/file or directory>


or using the mask



sudo chmod 070 <path/to/file or directory>


Note that using this solution you lose the control over the different permissions for ubuntu and www-data.






share|improve this answer


























  • you need to add the directory name in the last in your first command, right ?

    – Rooney
    Dec 1 '17 at 12:57











  • yes ofcourse .. I just thought if the user states he already changed the ownership he should know how to use chown ;)

    – derHugo
    Dec 1 '17 at 12:58











  • @T.Todua I mentioned it under Solution 1: Also interresting for your case might be the -R parameter.... was that not clear enough? I don't think that one of the two solutions is better or worse .. it depends on the use case which one fits better actually

    – derHugo
    Jan 8 at 20:56











  • dont take it, it was just my thought, ok. btw, can you mention two words about, why www-data shouldnt have write permision?

    – T.Todua
    Jan 8 at 20:57






  • 1





    I have four: It was an example. I only used it to show how the permission flags work. Ofcourse there might be use cases where e.g. the server should be able to write a file as well :)

    – derHugo
    Jan 8 at 21:01
















4














Solution 1



Easiest way if only that one user ubuntu and www-data need access would be



sudo chown ubuntu:www-data <path/to/file or directory>


this gives ownership to the user ubuntu but still keeps the ownership for the group www-data.



So you control what ubuntu can do by



sudo chmod u<+|- permission> <path/to/file or directory>


and you control what www-data can do by



sudo chmod g<+|- permission> <path/to/file or directory>


or simply use complete permission masks (see example below).





Example:

User ubuntu shall be able to read(r), write(w), execute(e)
www-data shall be able read(r), execute(e) but not write(w)
other users shall be able to do none of those



sudo chmod u+rwx <path/to/file or directory>
sudo chmod g-w+rx <path/to/file or directory>
sudo chmod o-rwx <path/to/file or directory>


or using a permission masks (helpful generator)



sudo chmod 750 <path/to/file or directory>




Also interresting for your case might be the -R parameter for both commands, applying ownership and permissions recursively on the content of a folder.



For more information about options and parameters see
man chown and
man chmod







Solution 2



I would rather NOT add a user to a system functional user's group as suggested in the comments like



sudo usermod -a -G www-data ubuntu an


as this is a really dirty way of granting a user permissions because he could also fuck up things...



Instead if you want you could add a completely new group using groupadd (see man groupadd)



groupadd <group name>


add all users who shall have the perissions on the file(s) to this group



sudo usermod -a -G <group name> ubuntu
sudo usermod -a -G <group name> www-data


and now set the ownership of the file(s) to this group



sudo chgrp <group name> <path/to/file or directory>


than you set the permissions as described before but this time only for the

group (read(r), write(w), execute(e))



sudo chmod g+rwx <path/to/file or directory>
sudo chmod u-rwx <path/to/file or directory>
sudo chmod o-rwx <path/to/file or directory>


or using the mask



sudo chmod 070 <path/to/file or directory>


Note that using this solution you lose the control over the different permissions for ubuntu and www-data.






share|improve this answer


























  • you need to add the directory name in the last in your first command, right ?

    – Rooney
    Dec 1 '17 at 12:57











  • yes ofcourse .. I just thought if the user states he already changed the ownership he should know how to use chown ;)

    – derHugo
    Dec 1 '17 at 12:58











  • @T.Todua I mentioned it under Solution 1: Also interresting for your case might be the -R parameter.... was that not clear enough? I don't think that one of the two solutions is better or worse .. it depends on the use case which one fits better actually

    – derHugo
    Jan 8 at 20:56











  • dont take it, it was just my thought, ok. btw, can you mention two words about, why www-data shouldnt have write permision?

    – T.Todua
    Jan 8 at 20:57






  • 1





    I have four: It was an example. I only used it to show how the permission flags work. Ofcourse there might be use cases where e.g. the server should be able to write a file as well :)

    – derHugo
    Jan 8 at 21:01














4












4








4







Solution 1



Easiest way if only that one user ubuntu and www-data need access would be



sudo chown ubuntu:www-data <path/to/file or directory>


this gives ownership to the user ubuntu but still keeps the ownership for the group www-data.



So you control what ubuntu can do by



sudo chmod u<+|- permission> <path/to/file or directory>


and you control what www-data can do by



sudo chmod g<+|- permission> <path/to/file or directory>


or simply use complete permission masks (see example below).





Example:

User ubuntu shall be able to read(r), write(w), execute(e)
www-data shall be able read(r), execute(e) but not write(w)
other users shall be able to do none of those



sudo chmod u+rwx <path/to/file or directory>
sudo chmod g-w+rx <path/to/file or directory>
sudo chmod o-rwx <path/to/file or directory>


or using a permission masks (helpful generator)



sudo chmod 750 <path/to/file or directory>




Also interresting for your case might be the -R parameter for both commands, applying ownership and permissions recursively on the content of a folder.



For more information about options and parameters see
man chown and
man chmod







Solution 2



I would rather NOT add a user to a system functional user's group as suggested in the comments like



sudo usermod -a -G www-data ubuntu an


as this is a really dirty way of granting a user permissions because he could also fuck up things...



Instead if you want you could add a completely new group using groupadd (see man groupadd)



groupadd <group name>


add all users who shall have the perissions on the file(s) to this group



sudo usermod -a -G <group name> ubuntu
sudo usermod -a -G <group name> www-data


and now set the ownership of the file(s) to this group



sudo chgrp <group name> <path/to/file or directory>


than you set the permissions as described before but this time only for the

group (read(r), write(w), execute(e))



sudo chmod g+rwx <path/to/file or directory>
sudo chmod u-rwx <path/to/file or directory>
sudo chmod o-rwx <path/to/file or directory>


or using the mask



sudo chmod 070 <path/to/file or directory>


Note that using this solution you lose the control over the different permissions for ubuntu and www-data.






share|improve this answer















Solution 1



Easiest way if only that one user ubuntu and www-data need access would be



sudo chown ubuntu:www-data <path/to/file or directory>


this gives ownership to the user ubuntu but still keeps the ownership for the group www-data.



So you control what ubuntu can do by



sudo chmod u<+|- permission> <path/to/file or directory>


and you control what www-data can do by



sudo chmod g<+|- permission> <path/to/file or directory>


or simply use complete permission masks (see example below).





Example:

User ubuntu shall be able to read(r), write(w), execute(e)
www-data shall be able read(r), execute(e) but not write(w)
other users shall be able to do none of those



sudo chmod u+rwx <path/to/file or directory>
sudo chmod g-w+rx <path/to/file or directory>
sudo chmod o-rwx <path/to/file or directory>


or using a permission masks (helpful generator)



sudo chmod 750 <path/to/file or directory>




Also interresting for your case might be the -R parameter for both commands, applying ownership and permissions recursively on the content of a folder.



For more information about options and parameters see
man chown and
man chmod







Solution 2



I would rather NOT add a user to a system functional user's group as suggested in the comments like



sudo usermod -a -G www-data ubuntu an


as this is a really dirty way of granting a user permissions because he could also fuck up things...



Instead if you want you could add a completely new group using groupadd (see man groupadd)



groupadd <group name>


add all users who shall have the perissions on the file(s) to this group



sudo usermod -a -G <group name> ubuntu
sudo usermod -a -G <group name> www-data


and now set the ownership of the file(s) to this group



sudo chgrp <group name> <path/to/file or directory>


than you set the permissions as described before but this time only for the

group (read(r), write(w), execute(e))



sudo chmod g+rwx <path/to/file or directory>
sudo chmod u-rwx <path/to/file or directory>
sudo chmod o-rwx <path/to/file or directory>


or using the mask



sudo chmod 070 <path/to/file or directory>


Note that using this solution you lose the control over the different permissions for ubuntu and www-data.







share|improve this answer














share|improve this answer



share|improve this answer








edited Jan 8 at 21:04

























answered Dec 1 '17 at 12:50









derHugoderHugo

2,29021429




2,29021429













  • you need to add the directory name in the last in your first command, right ?

    – Rooney
    Dec 1 '17 at 12:57











  • yes ofcourse .. I just thought if the user states he already changed the ownership he should know how to use chown ;)

    – derHugo
    Dec 1 '17 at 12:58











  • @T.Todua I mentioned it under Solution 1: Also interresting for your case might be the -R parameter.... was that not clear enough? I don't think that one of the two solutions is better or worse .. it depends on the use case which one fits better actually

    – derHugo
    Jan 8 at 20:56











  • dont take it, it was just my thought, ok. btw, can you mention two words about, why www-data shouldnt have write permision?

    – T.Todua
    Jan 8 at 20:57






  • 1





    I have four: It was an example. I only used it to show how the permission flags work. Ofcourse there might be use cases where e.g. the server should be able to write a file as well :)

    – derHugo
    Jan 8 at 21:01



















  • you need to add the directory name in the last in your first command, right ?

    – Rooney
    Dec 1 '17 at 12:57











  • yes ofcourse .. I just thought if the user states he already changed the ownership he should know how to use chown ;)

    – derHugo
    Dec 1 '17 at 12:58











  • @T.Todua I mentioned it under Solution 1: Also interresting for your case might be the -R parameter.... was that not clear enough? I don't think that one of the two solutions is better or worse .. it depends on the use case which one fits better actually

    – derHugo
    Jan 8 at 20:56











  • dont take it, it was just my thought, ok. btw, can you mention two words about, why www-data shouldnt have write permision?

    – T.Todua
    Jan 8 at 20:57






  • 1





    I have four: It was an example. I only used it to show how the permission flags work. Ofcourse there might be use cases where e.g. the server should be able to write a file as well :)

    – derHugo
    Jan 8 at 21:01

















you need to add the directory name in the last in your first command, right ?

– Rooney
Dec 1 '17 at 12:57





you need to add the directory name in the last in your first command, right ?

– Rooney
Dec 1 '17 at 12:57













yes ofcourse .. I just thought if the user states he already changed the ownership he should know how to use chown ;)

– derHugo
Dec 1 '17 at 12:58





yes ofcourse .. I just thought if the user states he already changed the ownership he should know how to use chown ;)

– derHugo
Dec 1 '17 at 12:58













@T.Todua I mentioned it under Solution 1: Also interresting for your case might be the -R parameter.... was that not clear enough? I don't think that one of the two solutions is better or worse .. it depends on the use case which one fits better actually

– derHugo
Jan 8 at 20:56





@T.Todua I mentioned it under Solution 1: Also interresting for your case might be the -R parameter.... was that not clear enough? I don't think that one of the two solutions is better or worse .. it depends on the use case which one fits better actually

– derHugo
Jan 8 at 20:56













dont take it, it was just my thought, ok. btw, can you mention two words about, why www-data shouldnt have write permision?

– T.Todua
Jan 8 at 20:57





dont take it, it was just my thought, ok. btw, can you mention two words about, why www-data shouldnt have write permision?

– T.Todua
Jan 8 at 20:57




1




1





I have four: It was an example. I only used it to show how the permission flags work. Ofcourse there might be use cases where e.g. the server should be able to write a file as well :)

– derHugo
Jan 8 at 21:01





I have four: It was an example. I only used it to show how the permission flags work. Ofcourse there might be use cases where e.g. the server should be able to write a file as well :)

– derHugo
Jan 8 at 21:01


















draft saved

draft discarded




















































Thanks for contributing an answer to Ask Ubuntu!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f982123%2fmultiple-owner-of-same-folder%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

flock() on closed filehandle LOCK_FILE at /usr/bin/apt-mirror

Mangá

 ⁒  ․,‪⁊‑⁙ ⁖, ⁇‒※‌, †,⁖‗‌⁝    ‾‸⁘,‖⁔⁣,⁂‾
”‑,‥–,‬ ,⁀‹⁋‴⁑ ‒ ,‴⁋”‼ ⁨,‷⁔„ ‰′,‐‚ ‥‡‎“‷⁃⁨⁅⁣,⁔
⁇‘⁔⁡⁏⁌⁡‿‶‏⁨ ⁣⁕⁖⁨⁩⁥‽⁀  ‴‬⁜‟ ⁃‣‧⁕‮ …‍⁨‴ ⁩,⁚⁖‫ ,‵ ⁀,‮⁝‣‣ ⁑  ⁂– ․, ‾‽ ‏⁁“⁗‸ ‾… ‹‡⁌⁎‸‘ ‡⁏⁌‪ ‵⁛ ‎⁨ ―⁦⁤⁄⁕