How to allow folder permission for another user in Linux?












0















Consider two user accounts user1 and user2 on one Linux machine. I want user2 to be able to have read and write access to a folder in user1 home directory.



So far created a group for both users and added both users



groupadd twousers
usermod -a -G twousers user1
usermod -a -G twousers user2


then changed the group and the path and changed the permission



chgrp twousers /home/user1/folder
chmod g+rwx /home/user1/folder


Unfortunately user2 is still unable to access the folder /home/user1/folder. It seems to be quite simple but somehow I am lost. What am I missing?










share|improve this question

























  • Something often missed is the permissions on the parent directory. It's possible that /home/user1 has no execute permission for user2. The simplest way to fix this would be chmod o+x /home/user1 since I guess you don't want to change the group on the home directory you need to give everyone execute permission on it.

    – Philip Couling
    4 hours ago











  • I swear that this exact same question was asked earlier this year but I wasn't able to locate it. Anyway, the other user can't access the directory because the home directory of each user is only traversable by the respective user. Rather than having the folder inside of another user's home, just put it in mnt and change the permissions in that directory or create an NFS export that only the two users can access.

    – Nasir Riley
    4 hours ago


















0















Consider two user accounts user1 and user2 on one Linux machine. I want user2 to be able to have read and write access to a folder in user1 home directory.



So far created a group for both users and added both users



groupadd twousers
usermod -a -G twousers user1
usermod -a -G twousers user2


then changed the group and the path and changed the permission



chgrp twousers /home/user1/folder
chmod g+rwx /home/user1/folder


Unfortunately user2 is still unable to access the folder /home/user1/folder. It seems to be quite simple but somehow I am lost. What am I missing?










share|improve this question

























  • Something often missed is the permissions on the parent directory. It's possible that /home/user1 has no execute permission for user2. The simplest way to fix this would be chmod o+x /home/user1 since I guess you don't want to change the group on the home directory you need to give everyone execute permission on it.

    – Philip Couling
    4 hours ago











  • I swear that this exact same question was asked earlier this year but I wasn't able to locate it. Anyway, the other user can't access the directory because the home directory of each user is only traversable by the respective user. Rather than having the folder inside of another user's home, just put it in mnt and change the permissions in that directory or create an NFS export that only the two users can access.

    – Nasir Riley
    4 hours ago
















0












0








0


1






Consider two user accounts user1 and user2 on one Linux machine. I want user2 to be able to have read and write access to a folder in user1 home directory.



So far created a group for both users and added both users



groupadd twousers
usermod -a -G twousers user1
usermod -a -G twousers user2


then changed the group and the path and changed the permission



chgrp twousers /home/user1/folder
chmod g+rwx /home/user1/folder


Unfortunately user2 is still unable to access the folder /home/user1/folder. It seems to be quite simple but somehow I am lost. What am I missing?










share|improve this question
















Consider two user accounts user1 and user2 on one Linux machine. I want user2 to be able to have read and write access to a folder in user1 home directory.



So far created a group for both users and added both users



groupadd twousers
usermod -a -G twousers user1
usermod -a -G twousers user2


then changed the group and the path and changed the permission



chgrp twousers /home/user1/folder
chmod g+rwx /home/user1/folder


Unfortunately user2 is still unable to access the folder /home/user1/folder. It seems to be quite simple but somehow I am lost. What am I missing?







permissions






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 1 hour ago









Paradox

171112




171112










asked 4 hours ago









A.DumasA.Dumas

5317




5317













  • Something often missed is the permissions on the parent directory. It's possible that /home/user1 has no execute permission for user2. The simplest way to fix this would be chmod o+x /home/user1 since I guess you don't want to change the group on the home directory you need to give everyone execute permission on it.

    – Philip Couling
    4 hours ago











  • I swear that this exact same question was asked earlier this year but I wasn't able to locate it. Anyway, the other user can't access the directory because the home directory of each user is only traversable by the respective user. Rather than having the folder inside of another user's home, just put it in mnt and change the permissions in that directory or create an NFS export that only the two users can access.

    – Nasir Riley
    4 hours ago





















  • Something often missed is the permissions on the parent directory. It's possible that /home/user1 has no execute permission for user2. The simplest way to fix this would be chmod o+x /home/user1 since I guess you don't want to change the group on the home directory you need to give everyone execute permission on it.

    – Philip Couling
    4 hours ago











  • I swear that this exact same question was asked earlier this year but I wasn't able to locate it. Anyway, the other user can't access the directory because the home directory of each user is only traversable by the respective user. Rather than having the folder inside of another user's home, just put it in mnt and change the permissions in that directory or create an NFS export that only the two users can access.

    – Nasir Riley
    4 hours ago



















Something often missed is the permissions on the parent directory. It's possible that /home/user1 has no execute permission for user2. The simplest way to fix this would be chmod o+x /home/user1 since I guess you don't want to change the group on the home directory you need to give everyone execute permission on it.

– Philip Couling
4 hours ago





Something often missed is the permissions on the parent directory. It's possible that /home/user1 has no execute permission for user2. The simplest way to fix this would be chmod o+x /home/user1 since I guess you don't want to change the group on the home directory you need to give everyone execute permission on it.

– Philip Couling
4 hours ago













I swear that this exact same question was asked earlier this year but I wasn't able to locate it. Anyway, the other user can't access the directory because the home directory of each user is only traversable by the respective user. Rather than having the folder inside of another user's home, just put it in mnt and change the permissions in that directory or create an NFS export that only the two users can access.

– Nasir Riley
4 hours ago







I swear that this exact same question was asked earlier this year but I wasn't able to locate it. Anyway, the other user can't access the directory because the home directory of each user is only traversable by the respective user. Rather than having the folder inside of another user's home, just put it in mnt and change the permissions in that directory or create an NFS export that only the two users can access.

– Nasir Riley
4 hours ago












1 Answer
1






active

oldest

votes


















0














The problem you are experiencing was to expect. Indeed, you are trying to share a folder inside another user home folder, which, for obvious security reasons, is (and should) only be accessible to the owner (and root, but that's another story).



In order to solve your problem, you should create another folder, where the potential parent(s) folder(s) will have the same permissions for both users e.g. /data/folder_to_share.



Here is a brief step-by-step example:





  • Create a parent folder (not necessary but it's for the sake of the example):



    # cd /
    # mkdir data



  • Create a shared subfolder:



    # cd data
    # mkdir shared_folder



  • optional : at this stage you could copy the content of the future shared folder into shared_folder.



    # cp -p  /path/to/folder/* /data/shared_folder/



  • Create a group share and two users bob and alice to it:



    # group add shared
    # usermod -aG share bob
    # usermod -aG share alice



  • Recursively change group folder ownership:



    # chgrp -R shared /data



  • Adding reading, writing and executing (only for files already executables) permissions for the group shared:



    # chmod -R g+rwX /data


  • Bob and Alice will now be able to do whatever they want inside the folder shared but as well in data.



Depending on your use case, you could just have one level but this example shows how the parent folder permissions can affect a folder deeper into the filesystem and allows for more scalability and granularity.






share|improve this answer

























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "106"
    };
    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: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    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%2funix.stackexchange.com%2fquestions%2f507571%2fhow-to-allow-folder-permission-for-another-user-in-linux%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









    0














    The problem you are experiencing was to expect. Indeed, you are trying to share a folder inside another user home folder, which, for obvious security reasons, is (and should) only be accessible to the owner (and root, but that's another story).



    In order to solve your problem, you should create another folder, where the potential parent(s) folder(s) will have the same permissions for both users e.g. /data/folder_to_share.



    Here is a brief step-by-step example:





    • Create a parent folder (not necessary but it's for the sake of the example):



      # cd /
      # mkdir data



    • Create a shared subfolder:



      # cd data
      # mkdir shared_folder



    • optional : at this stage you could copy the content of the future shared folder into shared_folder.



      # cp -p  /path/to/folder/* /data/shared_folder/



    • Create a group share and two users bob and alice to it:



      # group add shared
      # usermod -aG share bob
      # usermod -aG share alice



    • Recursively change group folder ownership:



      # chgrp -R shared /data



    • Adding reading, writing and executing (only for files already executables) permissions for the group shared:



      # chmod -R g+rwX /data


    • Bob and Alice will now be able to do whatever they want inside the folder shared but as well in data.



    Depending on your use case, you could just have one level but this example shows how the parent folder permissions can affect a folder deeper into the filesystem and allows for more scalability and granularity.






    share|improve this answer






























      0














      The problem you are experiencing was to expect. Indeed, you are trying to share a folder inside another user home folder, which, for obvious security reasons, is (and should) only be accessible to the owner (and root, but that's another story).



      In order to solve your problem, you should create another folder, where the potential parent(s) folder(s) will have the same permissions for both users e.g. /data/folder_to_share.



      Here is a brief step-by-step example:





      • Create a parent folder (not necessary but it's for the sake of the example):



        # cd /
        # mkdir data



      • Create a shared subfolder:



        # cd data
        # mkdir shared_folder



      • optional : at this stage you could copy the content of the future shared folder into shared_folder.



        # cp -p  /path/to/folder/* /data/shared_folder/



      • Create a group share and two users bob and alice to it:



        # group add shared
        # usermod -aG share bob
        # usermod -aG share alice



      • Recursively change group folder ownership:



        # chgrp -R shared /data



      • Adding reading, writing and executing (only for files already executables) permissions for the group shared:



        # chmod -R g+rwX /data


      • Bob and Alice will now be able to do whatever they want inside the folder shared but as well in data.



      Depending on your use case, you could just have one level but this example shows how the parent folder permissions can affect a folder deeper into the filesystem and allows for more scalability and granularity.






      share|improve this answer




























        0












        0








        0







        The problem you are experiencing was to expect. Indeed, you are trying to share a folder inside another user home folder, which, for obvious security reasons, is (and should) only be accessible to the owner (and root, but that's another story).



        In order to solve your problem, you should create another folder, where the potential parent(s) folder(s) will have the same permissions for both users e.g. /data/folder_to_share.



        Here is a brief step-by-step example:





        • Create a parent folder (not necessary but it's for the sake of the example):



          # cd /
          # mkdir data



        • Create a shared subfolder:



          # cd data
          # mkdir shared_folder



        • optional : at this stage you could copy the content of the future shared folder into shared_folder.



          # cp -p  /path/to/folder/* /data/shared_folder/



        • Create a group share and two users bob and alice to it:



          # group add shared
          # usermod -aG share bob
          # usermod -aG share alice



        • Recursively change group folder ownership:



          # chgrp -R shared /data



        • Adding reading, writing and executing (only for files already executables) permissions for the group shared:



          # chmod -R g+rwX /data


        • Bob and Alice will now be able to do whatever they want inside the folder shared but as well in data.



        Depending on your use case, you could just have one level but this example shows how the parent folder permissions can affect a folder deeper into the filesystem and allows for more scalability and granularity.






        share|improve this answer















        The problem you are experiencing was to expect. Indeed, you are trying to share a folder inside another user home folder, which, for obvious security reasons, is (and should) only be accessible to the owner (and root, but that's another story).



        In order to solve your problem, you should create another folder, where the potential parent(s) folder(s) will have the same permissions for both users e.g. /data/folder_to_share.



        Here is a brief step-by-step example:





        • Create a parent folder (not necessary but it's for the sake of the example):



          # cd /
          # mkdir data



        • Create a shared subfolder:



          # cd data
          # mkdir shared_folder



        • optional : at this stage you could copy the content of the future shared folder into shared_folder.



          # cp -p  /path/to/folder/* /data/shared_folder/



        • Create a group share and two users bob and alice to it:



          # group add shared
          # usermod -aG share bob
          # usermod -aG share alice



        • Recursively change group folder ownership:



          # chgrp -R shared /data



        • Adding reading, writing and executing (only for files already executables) permissions for the group shared:



          # chmod -R g+rwX /data


        • Bob and Alice will now be able to do whatever they want inside the folder shared but as well in data.



        Depending on your use case, you could just have one level but this example shows how the parent folder permissions can affect a folder deeper into the filesystem and allows for more scalability and granularity.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited 2 hours ago

























        answered 3 hours ago









        ParadoxParadox

        171112




        171112






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Unix & Linux Stack Exchange!


            • 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%2funix.stackexchange.com%2fquestions%2f507571%2fhow-to-allow-folder-permission-for-another-user-in-linux%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

            CARDNET

            Boot-repair Failure: Unable to locate package grub-common:i386

            濃尾地震