How to give permissions to a subfolder while denying access to folders above it

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











up vote
0
down vote

favorite












I have this structure:



/home/the_user/folder/subfolder



and I would like to have read and write access to it, but I want to be unable to read or write anything above it, that is



/home/the_user/folder



Is that possible?







share|improve this question
























    up vote
    0
    down vote

    favorite












    I have this structure:



    /home/the_user/folder/subfolder



    and I would like to have read and write access to it, but I want to be unable to read or write anything above it, that is



    /home/the_user/folder



    Is that possible?







    share|improve this question






















      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I have this structure:



      /home/the_user/folder/subfolder



      and I would like to have read and write access to it, but I want to be unable to read or write anything above it, that is



      /home/the_user/folder



      Is that possible?







      share|improve this question












      I have this structure:



      /home/the_user/folder/subfolder



      and I would like to have read and write access to it, but I want to be unable to read or write anything above it, that is



      /home/the_user/folder



      Is that possible?









      share|improve this question











      share|improve this question




      share|improve this question










      asked Apr 11 at 23:53









      Mephisto

      261112




      261112




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote













          It's better to do this in a location other than home such as creating the folder structure in / but here it goes:



          Set the owner of subfolder as the user you want to have read and write permissions.



          chown user /home/the_user/folder/subfolder
          chmod u+rwx /home/the_user/folder/subfolder


          Set execute for others on /home the_user and folder and make sure that there is no read and write for the user.



          chmod +x for each of them and chmod -rw for the user.



          That will allow the user to traverse the above directories but not read them or write to them while allowing him to read and write to subfolder.



          Once again, I recommend against doing this in /home and suggest that you create the directory as a subfolder of root such as:



          mkdir /mnt/folder



          ....and use my answer there instead of potentially making a mistake and giving permissions to someone's home directory.






          share|improve this answer






















          • No, this is wrong. With x permissions on /home/the_user/folder, you can access the files in it as their permissions permit. You can't list the directory contents, but if you know our guess the name of a file, you can check whether it exists, and can access it subject to that file's permissions.
            – Gilles
            Apr 12 at 7:46










          • My answer isn't wrong. It just doesn't cover every possible scenario which can be said of many of the answers in Stack Exchange especially when it comes to access and user rights. The one flaw is that a user can guess a filename in one of the higher folders and see that it exists by using lson the file itself but he still can't access it unless he has permissions. As the OP doesn't want that, it's up to him to make sure that the permissions don't allow that access. My answer doesn't allow him to list the directory contents for the higher directories so it effectively does what he wants.
            – Nasir Riley
            Apr 12 at 13:31











          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',
          convertImagesToLinks: false,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          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%2funix.stackexchange.com%2fquestions%2f437162%2fhow-to-give-permissions-to-a-subfolder-while-denying-access-to-folders-above-it%23new-answer', 'question_page');

          );

          Post as a guest






























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          0
          down vote













          It's better to do this in a location other than home such as creating the folder structure in / but here it goes:



          Set the owner of subfolder as the user you want to have read and write permissions.



          chown user /home/the_user/folder/subfolder
          chmod u+rwx /home/the_user/folder/subfolder


          Set execute for others on /home the_user and folder and make sure that there is no read and write for the user.



          chmod +x for each of them and chmod -rw for the user.



          That will allow the user to traverse the above directories but not read them or write to them while allowing him to read and write to subfolder.



          Once again, I recommend against doing this in /home and suggest that you create the directory as a subfolder of root such as:



          mkdir /mnt/folder



          ....and use my answer there instead of potentially making a mistake and giving permissions to someone's home directory.






          share|improve this answer






















          • No, this is wrong. With x permissions on /home/the_user/folder, you can access the files in it as their permissions permit. You can't list the directory contents, but if you know our guess the name of a file, you can check whether it exists, and can access it subject to that file's permissions.
            – Gilles
            Apr 12 at 7:46










          • My answer isn't wrong. It just doesn't cover every possible scenario which can be said of many of the answers in Stack Exchange especially when it comes to access and user rights. The one flaw is that a user can guess a filename in one of the higher folders and see that it exists by using lson the file itself but he still can't access it unless he has permissions. As the OP doesn't want that, it's up to him to make sure that the permissions don't allow that access. My answer doesn't allow him to list the directory contents for the higher directories so it effectively does what he wants.
            – Nasir Riley
            Apr 12 at 13:31















          up vote
          0
          down vote













          It's better to do this in a location other than home such as creating the folder structure in / but here it goes:



          Set the owner of subfolder as the user you want to have read and write permissions.



          chown user /home/the_user/folder/subfolder
          chmod u+rwx /home/the_user/folder/subfolder


          Set execute for others on /home the_user and folder and make sure that there is no read and write for the user.



          chmod +x for each of them and chmod -rw for the user.



          That will allow the user to traverse the above directories but not read them or write to them while allowing him to read and write to subfolder.



          Once again, I recommend against doing this in /home and suggest that you create the directory as a subfolder of root such as:



          mkdir /mnt/folder



          ....and use my answer there instead of potentially making a mistake and giving permissions to someone's home directory.






          share|improve this answer






















          • No, this is wrong. With x permissions on /home/the_user/folder, you can access the files in it as their permissions permit. You can't list the directory contents, but if you know our guess the name of a file, you can check whether it exists, and can access it subject to that file's permissions.
            – Gilles
            Apr 12 at 7:46










          • My answer isn't wrong. It just doesn't cover every possible scenario which can be said of many of the answers in Stack Exchange especially when it comes to access and user rights. The one flaw is that a user can guess a filename in one of the higher folders and see that it exists by using lson the file itself but he still can't access it unless he has permissions. As the OP doesn't want that, it's up to him to make sure that the permissions don't allow that access. My answer doesn't allow him to list the directory contents for the higher directories so it effectively does what he wants.
            – Nasir Riley
            Apr 12 at 13:31













          up vote
          0
          down vote










          up vote
          0
          down vote









          It's better to do this in a location other than home such as creating the folder structure in / but here it goes:



          Set the owner of subfolder as the user you want to have read and write permissions.



          chown user /home/the_user/folder/subfolder
          chmod u+rwx /home/the_user/folder/subfolder


          Set execute for others on /home the_user and folder and make sure that there is no read and write for the user.



          chmod +x for each of them and chmod -rw for the user.



          That will allow the user to traverse the above directories but not read them or write to them while allowing him to read and write to subfolder.



          Once again, I recommend against doing this in /home and suggest that you create the directory as a subfolder of root such as:



          mkdir /mnt/folder



          ....and use my answer there instead of potentially making a mistake and giving permissions to someone's home directory.






          share|improve this answer














          It's better to do this in a location other than home such as creating the folder structure in / but here it goes:



          Set the owner of subfolder as the user you want to have read and write permissions.



          chown user /home/the_user/folder/subfolder
          chmod u+rwx /home/the_user/folder/subfolder


          Set execute for others on /home the_user and folder and make sure that there is no read and write for the user.



          chmod +x for each of them and chmod -rw for the user.



          That will allow the user to traverse the above directories but not read them or write to them while allowing him to read and write to subfolder.



          Once again, I recommend against doing this in /home and suggest that you create the directory as a subfolder of root such as:



          mkdir /mnt/folder



          ....and use my answer there instead of potentially making a mistake and giving permissions to someone's home directory.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Apr 12 at 12:23

























          answered Apr 12 at 0:55









          Nasir Riley

          1,514138




          1,514138











          • No, this is wrong. With x permissions on /home/the_user/folder, you can access the files in it as their permissions permit. You can't list the directory contents, but if you know our guess the name of a file, you can check whether it exists, and can access it subject to that file's permissions.
            – Gilles
            Apr 12 at 7:46










          • My answer isn't wrong. It just doesn't cover every possible scenario which can be said of many of the answers in Stack Exchange especially when it comes to access and user rights. The one flaw is that a user can guess a filename in one of the higher folders and see that it exists by using lson the file itself but he still can't access it unless he has permissions. As the OP doesn't want that, it's up to him to make sure that the permissions don't allow that access. My answer doesn't allow him to list the directory contents for the higher directories so it effectively does what he wants.
            – Nasir Riley
            Apr 12 at 13:31

















          • No, this is wrong. With x permissions on /home/the_user/folder, you can access the files in it as their permissions permit. You can't list the directory contents, but if you know our guess the name of a file, you can check whether it exists, and can access it subject to that file's permissions.
            – Gilles
            Apr 12 at 7:46










          • My answer isn't wrong. It just doesn't cover every possible scenario which can be said of many of the answers in Stack Exchange especially when it comes to access and user rights. The one flaw is that a user can guess a filename in one of the higher folders and see that it exists by using lson the file itself but he still can't access it unless he has permissions. As the OP doesn't want that, it's up to him to make sure that the permissions don't allow that access. My answer doesn't allow him to list the directory contents for the higher directories so it effectively does what he wants.
            – Nasir Riley
            Apr 12 at 13:31
















          No, this is wrong. With x permissions on /home/the_user/folder, you can access the files in it as their permissions permit. You can't list the directory contents, but if you know our guess the name of a file, you can check whether it exists, and can access it subject to that file's permissions.
          – Gilles
          Apr 12 at 7:46




          No, this is wrong. With x permissions on /home/the_user/folder, you can access the files in it as their permissions permit. You can't list the directory contents, but if you know our guess the name of a file, you can check whether it exists, and can access it subject to that file's permissions.
          – Gilles
          Apr 12 at 7:46












          My answer isn't wrong. It just doesn't cover every possible scenario which can be said of many of the answers in Stack Exchange especially when it comes to access and user rights. The one flaw is that a user can guess a filename in one of the higher folders and see that it exists by using lson the file itself but he still can't access it unless he has permissions. As the OP doesn't want that, it's up to him to make sure that the permissions don't allow that access. My answer doesn't allow him to list the directory contents for the higher directories so it effectively does what he wants.
          – Nasir Riley
          Apr 12 at 13:31





          My answer isn't wrong. It just doesn't cover every possible scenario which can be said of many of the answers in Stack Exchange especially when it comes to access and user rights. The one flaw is that a user can guess a filename in one of the higher folders and see that it exists by using lson the file itself but he still can't access it unless he has permissions. As the OP doesn't want that, it's up to him to make sure that the permissions don't allow that access. My answer doesn't allow him to list the directory contents for the higher directories so it effectively does what he wants.
          – Nasir Riley
          Apr 12 at 13:31













           

          draft saved


          draft discarded


























           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f437162%2fhow-to-give-permissions-to-a-subfolder-while-denying-access-to-folders-above-it%23new-answer', 'question_page');

          );

          Post as a guest













































































          Popular posts from this blog

          Peggy Mitchell

          Palaiologos

          The Forum (Inglewood, California)