directory has a executable file mode












1















I am learning file mode permissions



666: for non-executable ordinary files 
777: for executable ordinary files
777: for directories


Reference to the executable mode,

I could understand that a program file has executable mode, but have

no ideas about why a directory also has a 'executable mode`.



I found it make no sense. a directory entry cannot be executed and cannot set all the files within a directory 'executable` by just set their directory.



How to understand a executable directory entry?










share|improve this question



























    1















    I am learning file mode permissions



    666: for non-executable ordinary files 
    777: for executable ordinary files
    777: for directories


    Reference to the executable mode,

    I could understand that a program file has executable mode, but have

    no ideas about why a directory also has a 'executable mode`.



    I found it make no sense. a directory entry cannot be executed and cannot set all the files within a directory 'executable` by just set their directory.



    How to understand a executable directory entry?










    share|improve this question

























      1












      1








      1








      I am learning file mode permissions



      666: for non-executable ordinary files 
      777: for executable ordinary files
      777: for directories


      Reference to the executable mode,

      I could understand that a program file has executable mode, but have

      no ideas about why a directory also has a 'executable mode`.



      I found it make no sense. a directory entry cannot be executed and cannot set all the files within a directory 'executable` by just set their directory.



      How to understand a executable directory entry?










      share|improve this question














      I am learning file mode permissions



      666: for non-executable ordinary files 
      777: for executable ordinary files
      777: for directories


      Reference to the executable mode,

      I could understand that a program file has executable mode, but have

      no ideas about why a directory also has a 'executable mode`.



      I found it make no sense. a directory entry cannot be executed and cannot set all the files within a directory 'executable` by just set their directory.



      How to understand a executable directory entry?







      bash






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jan 4 at 7:00









      user10726006user10726006

      903




      903






















          1 Answer
          1






          active

          oldest

          votes


















          2














          This has been covered in a related post on Unix&Linux:




          The execute bit (x) allows the affected user to enter the directory, and access files and directories inside




          An example:



          $ chmod -x test_access/
          $ cd test_access/
          bash: cd: test_access/: Permission denied


          This also prevents from creating/removing files:



          $ rm test_access/new_file 
          rm: cannot remove 'test_access/new_file': Permission denied
          $ touch test_access/another_file
          touch: cannot touch 'test_access/another_file': Permission denied




          The execute permission actually should be called "access" permission, since when there is no x bit set on file or directory, it results in EACCES error. You can see that when performing strace bash -c 'cd test_access/



          chdir("test_access")                    = -1 EACCES (Permission denied)


          On the lower level, this particular permission in stat.h standard Unix library is defined as




          S_IXUSR



          Execute/search permission, owner.




          Where search of course refers to directories. Note that reading what directory contains is covered by the r bit in the permissions. Thus, I can still ls the directory, but cannot navigate there if there's no x bit but there is r bit:



          $ ls -ld test_access
          drw-r--r-- 2 admin admin 4096 Jan 4 15:18 test_access
          $ ls test_access
          test_file


          If you look at strace output for rm and touch, you'll soon find out that these commands also use variation of stat() and openat() syscalls, which also return EACCES





          Side note on ls



          Note that on Debian systems with default /bin/bash as user's interactive shell, ls is often an alias to ls --color=auto. Where that's the case, you will see an error such as this:



          $ ls test_access 
          ls: cannot access 'test_access/test_file': Permission denied
          ls: cannot access 'test_access/new_file': Permission denied
          new_file test_file

          $ ls -l test_access
          ls: cannot access 'test_access/test_file': Permission denied
          ls: cannot access 'test_access/new_file': Permission denied
          total 0
          -????????? ? ? ? ? ? new_file
          -????????? ? ? ? ? ? test_file


          The reason behind that lies in the POSIX definition of EACCES:




          [EACCES] Permission bits of the file mode do not permit the requested
          access, or search permission is denied on a component of the path
          prefix




          Specifically, if you run strace ls --color=auto test_access/ you will see that ls attempts to perform lstat() system call to determine the directory entry type, which is where the EACCES occurs






          share|improve this answer

























            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%2f1106822%2fdirectory-has-a-executable-file-mode%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









            2














            This has been covered in a related post on Unix&Linux:




            The execute bit (x) allows the affected user to enter the directory, and access files and directories inside




            An example:



            $ chmod -x test_access/
            $ cd test_access/
            bash: cd: test_access/: Permission denied


            This also prevents from creating/removing files:



            $ rm test_access/new_file 
            rm: cannot remove 'test_access/new_file': Permission denied
            $ touch test_access/another_file
            touch: cannot touch 'test_access/another_file': Permission denied




            The execute permission actually should be called "access" permission, since when there is no x bit set on file or directory, it results in EACCES error. You can see that when performing strace bash -c 'cd test_access/



            chdir("test_access")                    = -1 EACCES (Permission denied)


            On the lower level, this particular permission in stat.h standard Unix library is defined as




            S_IXUSR



            Execute/search permission, owner.




            Where search of course refers to directories. Note that reading what directory contains is covered by the r bit in the permissions. Thus, I can still ls the directory, but cannot navigate there if there's no x bit but there is r bit:



            $ ls -ld test_access
            drw-r--r-- 2 admin admin 4096 Jan 4 15:18 test_access
            $ ls test_access
            test_file


            If you look at strace output for rm and touch, you'll soon find out that these commands also use variation of stat() and openat() syscalls, which also return EACCES





            Side note on ls



            Note that on Debian systems with default /bin/bash as user's interactive shell, ls is often an alias to ls --color=auto. Where that's the case, you will see an error such as this:



            $ ls test_access 
            ls: cannot access 'test_access/test_file': Permission denied
            ls: cannot access 'test_access/new_file': Permission denied
            new_file test_file

            $ ls -l test_access
            ls: cannot access 'test_access/test_file': Permission denied
            ls: cannot access 'test_access/new_file': Permission denied
            total 0
            -????????? ? ? ? ? ? new_file
            -????????? ? ? ? ? ? test_file


            The reason behind that lies in the POSIX definition of EACCES:




            [EACCES] Permission bits of the file mode do not permit the requested
            access, or search permission is denied on a component of the path
            prefix




            Specifically, if you run strace ls --color=auto test_access/ you will see that ls attempts to perform lstat() system call to determine the directory entry type, which is where the EACCES occurs






            share|improve this answer






























              2














              This has been covered in a related post on Unix&Linux:




              The execute bit (x) allows the affected user to enter the directory, and access files and directories inside




              An example:



              $ chmod -x test_access/
              $ cd test_access/
              bash: cd: test_access/: Permission denied


              This also prevents from creating/removing files:



              $ rm test_access/new_file 
              rm: cannot remove 'test_access/new_file': Permission denied
              $ touch test_access/another_file
              touch: cannot touch 'test_access/another_file': Permission denied




              The execute permission actually should be called "access" permission, since when there is no x bit set on file or directory, it results in EACCES error. You can see that when performing strace bash -c 'cd test_access/



              chdir("test_access")                    = -1 EACCES (Permission denied)


              On the lower level, this particular permission in stat.h standard Unix library is defined as




              S_IXUSR



              Execute/search permission, owner.




              Where search of course refers to directories. Note that reading what directory contains is covered by the r bit in the permissions. Thus, I can still ls the directory, but cannot navigate there if there's no x bit but there is r bit:



              $ ls -ld test_access
              drw-r--r-- 2 admin admin 4096 Jan 4 15:18 test_access
              $ ls test_access
              test_file


              If you look at strace output for rm and touch, you'll soon find out that these commands also use variation of stat() and openat() syscalls, which also return EACCES





              Side note on ls



              Note that on Debian systems with default /bin/bash as user's interactive shell, ls is often an alias to ls --color=auto. Where that's the case, you will see an error such as this:



              $ ls test_access 
              ls: cannot access 'test_access/test_file': Permission denied
              ls: cannot access 'test_access/new_file': Permission denied
              new_file test_file

              $ ls -l test_access
              ls: cannot access 'test_access/test_file': Permission denied
              ls: cannot access 'test_access/new_file': Permission denied
              total 0
              -????????? ? ? ? ? ? new_file
              -????????? ? ? ? ? ? test_file


              The reason behind that lies in the POSIX definition of EACCES:




              [EACCES] Permission bits of the file mode do not permit the requested
              access, or search permission is denied on a component of the path
              prefix




              Specifically, if you run strace ls --color=auto test_access/ you will see that ls attempts to perform lstat() system call to determine the directory entry type, which is where the EACCES occurs






              share|improve this answer




























                2












                2








                2







                This has been covered in a related post on Unix&Linux:




                The execute bit (x) allows the affected user to enter the directory, and access files and directories inside




                An example:



                $ chmod -x test_access/
                $ cd test_access/
                bash: cd: test_access/: Permission denied


                This also prevents from creating/removing files:



                $ rm test_access/new_file 
                rm: cannot remove 'test_access/new_file': Permission denied
                $ touch test_access/another_file
                touch: cannot touch 'test_access/another_file': Permission denied




                The execute permission actually should be called "access" permission, since when there is no x bit set on file or directory, it results in EACCES error. You can see that when performing strace bash -c 'cd test_access/



                chdir("test_access")                    = -1 EACCES (Permission denied)


                On the lower level, this particular permission in stat.h standard Unix library is defined as




                S_IXUSR



                Execute/search permission, owner.




                Where search of course refers to directories. Note that reading what directory contains is covered by the r bit in the permissions. Thus, I can still ls the directory, but cannot navigate there if there's no x bit but there is r bit:



                $ ls -ld test_access
                drw-r--r-- 2 admin admin 4096 Jan 4 15:18 test_access
                $ ls test_access
                test_file


                If you look at strace output for rm and touch, you'll soon find out that these commands also use variation of stat() and openat() syscalls, which also return EACCES





                Side note on ls



                Note that on Debian systems with default /bin/bash as user's interactive shell, ls is often an alias to ls --color=auto. Where that's the case, you will see an error such as this:



                $ ls test_access 
                ls: cannot access 'test_access/test_file': Permission denied
                ls: cannot access 'test_access/new_file': Permission denied
                new_file test_file

                $ ls -l test_access
                ls: cannot access 'test_access/test_file': Permission denied
                ls: cannot access 'test_access/new_file': Permission denied
                total 0
                -????????? ? ? ? ? ? new_file
                -????????? ? ? ? ? ? test_file


                The reason behind that lies in the POSIX definition of EACCES:




                [EACCES] Permission bits of the file mode do not permit the requested
                access, or search permission is denied on a component of the path
                prefix




                Specifically, if you run strace ls --color=auto test_access/ you will see that ls attempts to perform lstat() system call to determine the directory entry type, which is where the EACCES occurs






                share|improve this answer















                This has been covered in a related post on Unix&Linux:




                The execute bit (x) allows the affected user to enter the directory, and access files and directories inside




                An example:



                $ chmod -x test_access/
                $ cd test_access/
                bash: cd: test_access/: Permission denied


                This also prevents from creating/removing files:



                $ rm test_access/new_file 
                rm: cannot remove 'test_access/new_file': Permission denied
                $ touch test_access/another_file
                touch: cannot touch 'test_access/another_file': Permission denied




                The execute permission actually should be called "access" permission, since when there is no x bit set on file or directory, it results in EACCES error. You can see that when performing strace bash -c 'cd test_access/



                chdir("test_access")                    = -1 EACCES (Permission denied)


                On the lower level, this particular permission in stat.h standard Unix library is defined as




                S_IXUSR



                Execute/search permission, owner.




                Where search of course refers to directories. Note that reading what directory contains is covered by the r bit in the permissions. Thus, I can still ls the directory, but cannot navigate there if there's no x bit but there is r bit:



                $ ls -ld test_access
                drw-r--r-- 2 admin admin 4096 Jan 4 15:18 test_access
                $ ls test_access
                test_file


                If you look at strace output for rm and touch, you'll soon find out that these commands also use variation of stat() and openat() syscalls, which also return EACCES





                Side note on ls



                Note that on Debian systems with default /bin/bash as user's interactive shell, ls is often an alias to ls --color=auto. Where that's the case, you will see an error such as this:



                $ ls test_access 
                ls: cannot access 'test_access/test_file': Permission denied
                ls: cannot access 'test_access/new_file': Permission denied
                new_file test_file

                $ ls -l test_access
                ls: cannot access 'test_access/test_file': Permission denied
                ls: cannot access 'test_access/new_file': Permission denied
                total 0
                -????????? ? ? ? ? ? new_file
                -????????? ? ? ? ? ? test_file


                The reason behind that lies in the POSIX definition of EACCES:




                [EACCES] Permission bits of the file mode do not permit the requested
                access, or search permission is denied on a component of the path
                prefix




                Specifically, if you run strace ls --color=auto test_access/ you will see that ls attempts to perform lstat() system call to determine the directory entry type, which is where the EACCES occurs







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Jan 4 at 7:59

























                answered Jan 4 at 7:22









                Sergiy KolodyazhnyySergiy Kolodyazhnyy

                71.3k9147313




                71.3k9147313






























                    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%2f1106822%2fdirectory-has-a-executable-file-mode%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

                    Quarter-circle Tiles

                    build a pushdown automaton that recognizes the reverse language of a given pushdown automaton?

                    Mont Emei