Chmod equivalence of +x and 0755











up vote
6
down vote

favorite
2












Just curious, are these two completely equivalent?



chmod +x file
chmod 0755 file









share|improve this question















migrated from stackoverflow.com Mar 25 '12 at 14:20


This question came from our site for professional and enthusiast programmers.











  • 2




    No, because +x just adds x to the current mask for everybody, not influencing rw, while 0755 changes the whole mask.
    – Ondrej Kupka
    Mar 25 '12 at 13:07










  • -1 You would have found this out if you read the man page for chmod and possibly the wpedia page for Filesystem permissions.
    – Eroen
    Apr 19 '12 at 15:55















up vote
6
down vote

favorite
2












Just curious, are these two completely equivalent?



chmod +x file
chmod 0755 file









share|improve this question















migrated from stackoverflow.com Mar 25 '12 at 14:20


This question came from our site for professional and enthusiast programmers.











  • 2




    No, because +x just adds x to the current mask for everybody, not influencing rw, while 0755 changes the whole mask.
    – Ondrej Kupka
    Mar 25 '12 at 13:07










  • -1 You would have found this out if you read the man page for chmod and possibly the wpedia page for Filesystem permissions.
    – Eroen
    Apr 19 '12 at 15:55













up vote
6
down vote

favorite
2









up vote
6
down vote

favorite
2






2





Just curious, are these two completely equivalent?



chmod +x file
chmod 0755 file









share|improve this question















Just curious, are these two completely equivalent?



chmod +x file
chmod 0755 file






bash shell






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 19 '16 at 22:10









DavidPostill

102k25218254




102k25218254










asked Mar 25 '12 at 13:06









rluks

2801312




2801312




migrated from stackoverflow.com Mar 25 '12 at 14:20


This question came from our site for professional and enthusiast programmers.






migrated from stackoverflow.com Mar 25 '12 at 14:20


This question came from our site for professional and enthusiast programmers.










  • 2




    No, because +x just adds x to the current mask for everybody, not influencing rw, while 0755 changes the whole mask.
    – Ondrej Kupka
    Mar 25 '12 at 13:07










  • -1 You would have found this out if you read the man page for chmod and possibly the wpedia page for Filesystem permissions.
    – Eroen
    Apr 19 '12 at 15:55














  • 2




    No, because +x just adds x to the current mask for everybody, not influencing rw, while 0755 changes the whole mask.
    – Ondrej Kupka
    Mar 25 '12 at 13:07










  • -1 You would have found this out if you read the man page for chmod and possibly the wpedia page for Filesystem permissions.
    – Eroen
    Apr 19 '12 at 15:55








2




2




No, because +x just adds x to the current mask for everybody, not influencing rw, while 0755 changes the whole mask.
– Ondrej Kupka
Mar 25 '12 at 13:07




No, because +x just adds x to the current mask for everybody, not influencing rw, while 0755 changes the whole mask.
– Ondrej Kupka
Mar 25 '12 at 13:07












-1 You would have found this out if you read the man page for chmod and possibly the wpedia page for Filesystem permissions.
– Eroen
Apr 19 '12 at 15:55




-1 You would have found this out if you read the man page for chmod and possibly the wpedia page for Filesystem permissions.
– Eroen
Apr 19 '12 at 15:55










4 Answers
4






active

oldest

votes

















up vote
7
down vote



accepted










chmod 0755 file is equivalent to u=rwx (4+2+1),go=rx (4+1 & 4+1). The 0 specifies default special modes (see comment below). See wikipedia for more info (including tables describing u,g,o,a and r,w,x,s,t,).



So in other words: No, they're not equivalent since 0755 contains more flags.



See also: chmod man page






share|improve this answer























  • That's not accurate. The 0 specifies set UID (4), get GID (2) and sticky bit (1) in the first of the 4 numbers. If omitted, it assumes a padded 0 on the front.
    – iandouglas
    Mar 25 '12 at 13:12










  • @iandouglas But "if omitted, it assumes a padded 0 on the front", should then mean that 0 is the default? So in other words, you're just saying that it should say "no special special modes" ?
    – keyser5053
    Mar 25 '12 at 13:26










  • To my knowledge, yes, 0 is an implied default, so "755" should be the same as "0755"
    – iandouglas
    Mar 25 '12 at 13:54










  • @iandouglas post edited
    – keyser5053
    Mar 25 '12 at 13:57


















up vote
6
down vote













Chmod number sets the permissions to exactly that number. Chmod relative only changes the requested bits. A file whose permissions were 000 before chmod +x will now be 111. Conversely, a file whose permissions were 0775 before (read+write+execute for owner and group; read and execute for others) will be unchanged by chmod +x, whereas setting the mode to exactly 0755 will change the 020 bit (remove write access for group).






share|improve this answer






























    up vote
    3
    down vote













    No, because chmod 755 also sets various read and write flags.






    share|improve this answer




























      up vote
      0
      down vote













      Assuming your file was already chmod 644, then, yes, they are effectively equal. It's better to explicitly list the bits you want to set though, using something like a+x






      share|improve this answer





















        Your Answer








        StackExchange.ready(function() {
        var channelOptions = {
        tags: "".split(" "),
        id: "3"
        };
        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: 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%2fsuperuser.com%2fquestions%2f404592%2fchmod-equivalence-of-x-and-0755%23new-answer', 'question_page');
        }
        );

        Post as a guest















        Required, but never shown

























        4 Answers
        4






        active

        oldest

        votes








        4 Answers
        4






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes








        up vote
        7
        down vote



        accepted










        chmod 0755 file is equivalent to u=rwx (4+2+1),go=rx (4+1 & 4+1). The 0 specifies default special modes (see comment below). See wikipedia for more info (including tables describing u,g,o,a and r,w,x,s,t,).



        So in other words: No, they're not equivalent since 0755 contains more flags.



        See also: chmod man page






        share|improve this answer























        • That's not accurate. The 0 specifies set UID (4), get GID (2) and sticky bit (1) in the first of the 4 numbers. If omitted, it assumes a padded 0 on the front.
          – iandouglas
          Mar 25 '12 at 13:12










        • @iandouglas But "if omitted, it assumes a padded 0 on the front", should then mean that 0 is the default? So in other words, you're just saying that it should say "no special special modes" ?
          – keyser5053
          Mar 25 '12 at 13:26










        • To my knowledge, yes, 0 is an implied default, so "755" should be the same as "0755"
          – iandouglas
          Mar 25 '12 at 13:54










        • @iandouglas post edited
          – keyser5053
          Mar 25 '12 at 13:57















        up vote
        7
        down vote



        accepted










        chmod 0755 file is equivalent to u=rwx (4+2+1),go=rx (4+1 & 4+1). The 0 specifies default special modes (see comment below). See wikipedia for more info (including tables describing u,g,o,a and r,w,x,s,t,).



        So in other words: No, they're not equivalent since 0755 contains more flags.



        See also: chmod man page






        share|improve this answer























        • That's not accurate. The 0 specifies set UID (4), get GID (2) and sticky bit (1) in the first of the 4 numbers. If omitted, it assumes a padded 0 on the front.
          – iandouglas
          Mar 25 '12 at 13:12










        • @iandouglas But "if omitted, it assumes a padded 0 on the front", should then mean that 0 is the default? So in other words, you're just saying that it should say "no special special modes" ?
          – keyser5053
          Mar 25 '12 at 13:26










        • To my knowledge, yes, 0 is an implied default, so "755" should be the same as "0755"
          – iandouglas
          Mar 25 '12 at 13:54










        • @iandouglas post edited
          – keyser5053
          Mar 25 '12 at 13:57













        up vote
        7
        down vote



        accepted







        up vote
        7
        down vote



        accepted






        chmod 0755 file is equivalent to u=rwx (4+2+1),go=rx (4+1 & 4+1). The 0 specifies default special modes (see comment below). See wikipedia for more info (including tables describing u,g,o,a and r,w,x,s,t,).



        So in other words: No, they're not equivalent since 0755 contains more flags.



        See also: chmod man page






        share|improve this answer














        chmod 0755 file is equivalent to u=rwx (4+2+1),go=rx (4+1 & 4+1). The 0 specifies default special modes (see comment below). See wikipedia for more info (including tables describing u,g,o,a and r,w,x,s,t,).



        So in other words: No, they're not equivalent since 0755 contains more flags.



        See also: chmod man page







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Jul 28 '14 at 14:22

























        answered Mar 25 '12 at 13:10









        keyser

        1865




        1865












        • That's not accurate. The 0 specifies set UID (4), get GID (2) and sticky bit (1) in the first of the 4 numbers. If omitted, it assumes a padded 0 on the front.
          – iandouglas
          Mar 25 '12 at 13:12










        • @iandouglas But "if omitted, it assumes a padded 0 on the front", should then mean that 0 is the default? So in other words, you're just saying that it should say "no special special modes" ?
          – keyser5053
          Mar 25 '12 at 13:26










        • To my knowledge, yes, 0 is an implied default, so "755" should be the same as "0755"
          – iandouglas
          Mar 25 '12 at 13:54










        • @iandouglas post edited
          – keyser5053
          Mar 25 '12 at 13:57


















        • That's not accurate. The 0 specifies set UID (4), get GID (2) and sticky bit (1) in the first of the 4 numbers. If omitted, it assumes a padded 0 on the front.
          – iandouglas
          Mar 25 '12 at 13:12










        • @iandouglas But "if omitted, it assumes a padded 0 on the front", should then mean that 0 is the default? So in other words, you're just saying that it should say "no special special modes" ?
          – keyser5053
          Mar 25 '12 at 13:26










        • To my knowledge, yes, 0 is an implied default, so "755" should be the same as "0755"
          – iandouglas
          Mar 25 '12 at 13:54










        • @iandouglas post edited
          – keyser5053
          Mar 25 '12 at 13:57
















        That's not accurate. The 0 specifies set UID (4), get GID (2) and sticky bit (1) in the first of the 4 numbers. If omitted, it assumes a padded 0 on the front.
        – iandouglas
        Mar 25 '12 at 13:12




        That's not accurate. The 0 specifies set UID (4), get GID (2) and sticky bit (1) in the first of the 4 numbers. If omitted, it assumes a padded 0 on the front.
        – iandouglas
        Mar 25 '12 at 13:12












        @iandouglas But "if omitted, it assumes a padded 0 on the front", should then mean that 0 is the default? So in other words, you're just saying that it should say "no special special modes" ?
        – keyser5053
        Mar 25 '12 at 13:26




        @iandouglas But "if omitted, it assumes a padded 0 on the front", should then mean that 0 is the default? So in other words, you're just saying that it should say "no special special modes" ?
        – keyser5053
        Mar 25 '12 at 13:26












        To my knowledge, yes, 0 is an implied default, so "755" should be the same as "0755"
        – iandouglas
        Mar 25 '12 at 13:54




        To my knowledge, yes, 0 is an implied default, so "755" should be the same as "0755"
        – iandouglas
        Mar 25 '12 at 13:54












        @iandouglas post edited
        – keyser5053
        Mar 25 '12 at 13:57




        @iandouglas post edited
        – keyser5053
        Mar 25 '12 at 13:57












        up vote
        6
        down vote













        Chmod number sets the permissions to exactly that number. Chmod relative only changes the requested bits. A file whose permissions were 000 before chmod +x will now be 111. Conversely, a file whose permissions were 0775 before (read+write+execute for owner and group; read and execute for others) will be unchanged by chmod +x, whereas setting the mode to exactly 0755 will change the 020 bit (remove write access for group).






        share|improve this answer



























          up vote
          6
          down vote













          Chmod number sets the permissions to exactly that number. Chmod relative only changes the requested bits. A file whose permissions were 000 before chmod +x will now be 111. Conversely, a file whose permissions were 0775 before (read+write+execute for owner and group; read and execute for others) will be unchanged by chmod +x, whereas setting the mode to exactly 0755 will change the 020 bit (remove write access for group).






          share|improve this answer

























            up vote
            6
            down vote










            up vote
            6
            down vote









            Chmod number sets the permissions to exactly that number. Chmod relative only changes the requested bits. A file whose permissions were 000 before chmod +x will now be 111. Conversely, a file whose permissions were 0775 before (read+write+execute for owner and group; read and execute for others) will be unchanged by chmod +x, whereas setting the mode to exactly 0755 will change the 020 bit (remove write access for group).






            share|improve this answer














            Chmod number sets the permissions to exactly that number. Chmod relative only changes the requested bits. A file whose permissions were 000 before chmod +x will now be 111. Conversely, a file whose permissions were 0775 before (read+write+execute for owner and group; read and execute for others) will be unchanged by chmod +x, whereas setting the mode to exactly 0755 will change the 020 bit (remove write access for group).







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Nov 23 at 15:12

























            answered Mar 25 '12 at 14:24









            tripleee

            1,72832130




            1,72832130






















                up vote
                3
                down vote













                No, because chmod 755 also sets various read and write flags.






                share|improve this answer

























                  up vote
                  3
                  down vote













                  No, because chmod 755 also sets various read and write flags.






                  share|improve this answer























                    up vote
                    3
                    down vote










                    up vote
                    3
                    down vote









                    No, because chmod 755 also sets various read and write flags.






                    share|improve this answer












                    No, because chmod 755 also sets various read and write flags.







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Mar 25 '12 at 13:10









                    Oliver Charlesworth

                    937510




                    937510






















                        up vote
                        0
                        down vote













                        Assuming your file was already chmod 644, then, yes, they are effectively equal. It's better to explicitly list the bits you want to set though, using something like a+x






                        share|improve this answer

























                          up vote
                          0
                          down vote













                          Assuming your file was already chmod 644, then, yes, they are effectively equal. It's better to explicitly list the bits you want to set though, using something like a+x






                          share|improve this answer























                            up vote
                            0
                            down vote










                            up vote
                            0
                            down vote









                            Assuming your file was already chmod 644, then, yes, they are effectively equal. It's better to explicitly list the bits you want to set though, using something like a+x






                            share|improve this answer












                            Assuming your file was already chmod 644, then, yes, they are effectively equal. It's better to explicitly list the bits you want to set though, using something like a+x







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Mar 25 '12 at 13:14









                            iandouglas

                            1092




                            1092






























                                draft saved

                                draft discarded




















































                                Thanks for contributing an answer to Super User!


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





                                Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                                Please pay close attention to the following guidance:


                                • 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%2fsuperuser.com%2fquestions%2f404592%2fchmod-equivalence-of-x-and-0755%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

                                "Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

                                Alcedinidae

                                Origin of the phrase “under your belt”?