Removing and adding permission using numerical notation on the same line

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











up vote
5
down vote

favorite












I'm having some trouble trying to remove write permission from the owning group (g), and to add read permission to others (o) at the same time.



How would I remove some permission from the owning group and add some permission for others in the same line?










share|improve this question









New contributor




Zanders2001 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.



















  • Hello and welcome on UL. I find this question rather unclear. Don't hesitate to provide more context and example of desired behaviour so that it'll be easier for people to understand what you mean :)
    – iago-lito
    Sep 9 at 21:22














up vote
5
down vote

favorite












I'm having some trouble trying to remove write permission from the owning group (g), and to add read permission to others (o) at the same time.



How would I remove some permission from the owning group and add some permission for others in the same line?










share|improve this question









New contributor




Zanders2001 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.



















  • Hello and welcome on UL. I find this question rather unclear. Don't hesitate to provide more context and example of desired behaviour so that it'll be easier for people to understand what you mean :)
    – iago-lito
    Sep 9 at 21:22












up vote
5
down vote

favorite









up vote
5
down vote

favorite











I'm having some trouble trying to remove write permission from the owning group (g), and to add read permission to others (o) at the same time.



How would I remove some permission from the owning group and add some permission for others in the same line?










share|improve this question









New contributor




Zanders2001 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











I'm having some trouble trying to remove write permission from the owning group (g), and to add read permission to others (o) at the same time.



How would I remove some permission from the owning group and add some permission for others in the same line?







linux chmod






share|improve this question









New contributor




Zanders2001 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Zanders2001 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 2 days ago









ilkkachu

50.8k678140




50.8k678140






New contributor




Zanders2001 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked Sep 9 at 20:41









Zanders2001

282




282




New contributor




Zanders2001 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Zanders2001 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Zanders2001 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











  • Hello and welcome on UL. I find this question rather unclear. Don't hesitate to provide more context and example of desired behaviour so that it'll be easier for people to understand what you mean :)
    – iago-lito
    Sep 9 at 21:22
















  • Hello and welcome on UL. I find this question rather unclear. Don't hesitate to provide more context and example of desired behaviour so that it'll be easier for people to understand what you mean :)
    – iago-lito
    Sep 9 at 21:22















Hello and welcome on UL. I find this question rather unclear. Don't hesitate to provide more context and example of desired behaviour so that it'll be easier for people to understand what you mean :)
– iago-lito
Sep 9 at 21:22




Hello and welcome on UL. I find this question rather unclear. Don't hesitate to provide more context and example of desired behaviour so that it'll be easier for people to understand what you mean :)
– iago-lito
Sep 9 at 21:22










5 Answers
5






active

oldest

votes

















up vote
10
down vote



accepted










Noting the title of your question:




Removing and adding permission using numerical notation on the same line




With chmod from GNU coreutils, which you probably have on a Linux system, you could use



$ chmod -020,+004 test.txt


to do that. It works in the obvious way: middle digit for the group, 2 is for write; and last digit for "others", and 4 for read.



Being able to use + or - with a numerical mode is a GNU extension, e.g. the BSD-based chmod on my Mac gives an error for +004:



$ chmod +004 test.txt
chmod: Invalid file mode: +004


So it would be simpler, shorter, more portable and probably more readable to just use the symbolic form:



$ chmod g-w,o+r test.txt





share|improve this answer






















  • Upvoting because it's almost always best to write symbolic form rather than numeric. I've found by painful experience that people often make errors with numerical form of chmod when they think they're adding permissions but are actually removing some as well. This GNU extension at least avoids that problem, but precisely because it's not POSIX, one must be careful to only use it in a domain where it's assured to be supported.
    – Monty Harder
    2 days ago

















up vote
5
down vote













EDIT: Seeing ilkkachu's answer, made me test this, and the syntax he describes works, but the man page on my system (which I had checked) says




can be either a symbolic representation of changes to make, or an octal number representing the bit pattern for the new mode bits




which was what caused me to write the original answer (below). I guess it's a new change and that they forgot to update the man page.



Original answer below:



The title of your questions mentions "numerical notation", if by that you mean specifying modes as octal numbers, the answer is that you can't specify changes with that, only the new mode of the file(s).






share|improve this answer






















  • You're right, it's not on the man page. GNU likes the info pages, so you need to read them. Or the online manual which is probably generated from the same data. I added a link to it in my answer.
    – ilkkachu
    2 days ago

















up vote
4
down vote













As the 2nd line of man page says:



chmod g-w,o+r file


$ man chmod



CHMOD(1) User Commands CHMOD(1)

NAME
chmod - change file mode bits

SYNOPSIS
chmod [OPTION]... MODE[,MODE]... FILE...


or the 1st line of chmod --help



Usage: chmod [OPTION]... MODE[,MODE]... FILE...





share|improve this answer



























    up vote
    3
    down vote













    Standardly, only the symbolic form allows adding and removing bits from the current permissions (though see @ilkkachu's answer if you're on a GNU system where chmod supports it with the numerical form as an extension).



    With the numerical octal form, the number you give is the new set of permission bits, regardless of what the previous value was.



    You could however get the previous value by hand and apply the modifications as a bit-logical operation.



    For instance, with zsh:



    zmodload zsh/stat
    zstat -A mode +mode -- "$file" &&
    perms=$((mode & 8#7777)) &&
    chmod -- $(((perms | 4) & ~ 8#20)) "$file"


    That's binary OR (|) with 4 to add the read permission to others and binary AND (&) with the binary NOT (~) of octal 20 to remove the write permissions to group.



    For instance, if the previous permission bits (st_mode & 0777) were 0660 (rw-rw----), 0660 | 4 would be 0664 (rw-rw-r--), and 0664 & ~ 020 would be 0644 (rw-r--r--).



    Now, I'm not sure why you'd want to do that instead of:



    chmod -- g-w,o+r "$file"





    share|improve this answer





























      up vote
      0
      down vote













      Since you didn't specify a reason for why you want to do it that way. I'll assume you don't know that it is way faster (and imho more precise) to simply set the desired mode, than to flip the flags one after another.



      Explained in simplified terms:
      Specify 3 numerical values for the set/unset state of all the read, write, and execute flags. For owner, group, and others all at once.



      To simplify, I'll stick to 3 digits.
      But you should look at the rest of the flags too when you get used to this way of doing it.



      To simplify even more:
      These 3 values are separate positional values, and not a three digit number. The first one sets the permissions for owner, the next one sets the permissions for group, and the third, sets the permissions for everyone else (others).



      Setting the flags:
      Now. Determining what each digit means is where some people get confused, but it's really simple when you first learn how it's done.



      Here are the flag-values:



      • 1=execute

      • 2=write

      • 4=read

      Now, you simply do one position at a time, and add (sum) the desired flag-values together. If you want to set read and execute: 4+1=5. If you want read and write but not execute: 4+2=6.



      Examples




      | ### | Owner | Group | Others |
      | --- | --- | --- | --- |
      | 755 | RWX | R-X | R-X |
      | 644 | RW- | R-- | R-- |


      Extra info and more examples can be seen here:
      https://linux.die.net/Linux-CLI/file-permissions.html



      So if you want group and others to only have read permission, but owner should have read and write, you simply do chmod 644 FILENAME



      Here's a great tutorial: Understanding Linux File Permissions



      One last tip:
      Remember that users need execute permission for directories to list the content.






      share|improve this answer








      New contributor




      svin83 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.

















        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
        );



        );






        Zanders2001 is a new contributor. Be nice, and check out our Code of Conduct.









         

        draft saved


        draft discarded


















        StackExchange.ready(
        function ()
        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f467925%2fremoving-and-adding-permission-using-numerical-notation-on-the-same-line%23new-answer', 'question_page');

        );

        Post as a guest






























        5 Answers
        5






        active

        oldest

        votes








        5 Answers
        5






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes








        up vote
        10
        down vote



        accepted










        Noting the title of your question:




        Removing and adding permission using numerical notation on the same line




        With chmod from GNU coreutils, which you probably have on a Linux system, you could use



        $ chmod -020,+004 test.txt


        to do that. It works in the obvious way: middle digit for the group, 2 is for write; and last digit for "others", and 4 for read.



        Being able to use + or - with a numerical mode is a GNU extension, e.g. the BSD-based chmod on my Mac gives an error for +004:



        $ chmod +004 test.txt
        chmod: Invalid file mode: +004


        So it would be simpler, shorter, more portable and probably more readable to just use the symbolic form:



        $ chmod g-w,o+r test.txt





        share|improve this answer






















        • Upvoting because it's almost always best to write symbolic form rather than numeric. I've found by painful experience that people often make errors with numerical form of chmod when they think they're adding permissions but are actually removing some as well. This GNU extension at least avoids that problem, but precisely because it's not POSIX, one must be careful to only use it in a domain where it's assured to be supported.
          – Monty Harder
          2 days ago














        up vote
        10
        down vote



        accepted










        Noting the title of your question:




        Removing and adding permission using numerical notation on the same line




        With chmod from GNU coreutils, which you probably have on a Linux system, you could use



        $ chmod -020,+004 test.txt


        to do that. It works in the obvious way: middle digit for the group, 2 is for write; and last digit for "others", and 4 for read.



        Being able to use + or - with a numerical mode is a GNU extension, e.g. the BSD-based chmod on my Mac gives an error for +004:



        $ chmod +004 test.txt
        chmod: Invalid file mode: +004


        So it would be simpler, shorter, more portable and probably more readable to just use the symbolic form:



        $ chmod g-w,o+r test.txt





        share|improve this answer






















        • Upvoting because it's almost always best to write symbolic form rather than numeric. I've found by painful experience that people often make errors with numerical form of chmod when they think they're adding permissions but are actually removing some as well. This GNU extension at least avoids that problem, but precisely because it's not POSIX, one must be careful to only use it in a domain where it's assured to be supported.
          – Monty Harder
          2 days ago












        up vote
        10
        down vote



        accepted







        up vote
        10
        down vote



        accepted






        Noting the title of your question:




        Removing and adding permission using numerical notation on the same line




        With chmod from GNU coreutils, which you probably have on a Linux system, you could use



        $ chmod -020,+004 test.txt


        to do that. It works in the obvious way: middle digit for the group, 2 is for write; and last digit for "others", and 4 for read.



        Being able to use + or - with a numerical mode is a GNU extension, e.g. the BSD-based chmod on my Mac gives an error for +004:



        $ chmod +004 test.txt
        chmod: Invalid file mode: +004


        So it would be simpler, shorter, more portable and probably more readable to just use the symbolic form:



        $ chmod g-w,o+r test.txt





        share|improve this answer














        Noting the title of your question:




        Removing and adding permission using numerical notation on the same line




        With chmod from GNU coreutils, which you probably have on a Linux system, you could use



        $ chmod -020,+004 test.txt


        to do that. It works in the obvious way: middle digit for the group, 2 is for write; and last digit for "others", and 4 for read.



        Being able to use + or - with a numerical mode is a GNU extension, e.g. the BSD-based chmod on my Mac gives an error for +004:



        $ chmod +004 test.txt
        chmod: Invalid file mode: +004


        So it would be simpler, shorter, more portable and probably more readable to just use the symbolic form:



        $ chmod g-w,o+r test.txt






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited 2 days ago

























        answered 2 days ago









        ilkkachu

        50.8k678140




        50.8k678140











        • Upvoting because it's almost always best to write symbolic form rather than numeric. I've found by painful experience that people often make errors with numerical form of chmod when they think they're adding permissions but are actually removing some as well. This GNU extension at least avoids that problem, but precisely because it's not POSIX, one must be careful to only use it in a domain where it's assured to be supported.
          – Monty Harder
          2 days ago
















        • Upvoting because it's almost always best to write symbolic form rather than numeric. I've found by painful experience that people often make errors with numerical form of chmod when they think they're adding permissions but are actually removing some as well. This GNU extension at least avoids that problem, but precisely because it's not POSIX, one must be careful to only use it in a domain where it's assured to be supported.
          – Monty Harder
          2 days ago















        Upvoting because it's almost always best to write symbolic form rather than numeric. I've found by painful experience that people often make errors with numerical form of chmod when they think they're adding permissions but are actually removing some as well. This GNU extension at least avoids that problem, but precisely because it's not POSIX, one must be careful to only use it in a domain where it's assured to be supported.
        – Monty Harder
        2 days ago




        Upvoting because it's almost always best to write symbolic form rather than numeric. I've found by painful experience that people often make errors with numerical form of chmod when they think they're adding permissions but are actually removing some as well. This GNU extension at least avoids that problem, but precisely because it's not POSIX, one must be careful to only use it in a domain where it's assured to be supported.
        – Monty Harder
        2 days ago












        up vote
        5
        down vote













        EDIT: Seeing ilkkachu's answer, made me test this, and the syntax he describes works, but the man page on my system (which I had checked) says




        can be either a symbolic representation of changes to make, or an octal number representing the bit pattern for the new mode bits




        which was what caused me to write the original answer (below). I guess it's a new change and that they forgot to update the man page.



        Original answer below:



        The title of your questions mentions "numerical notation", if by that you mean specifying modes as octal numbers, the answer is that you can't specify changes with that, only the new mode of the file(s).






        share|improve this answer






















        • You're right, it's not on the man page. GNU likes the info pages, so you need to read them. Or the online manual which is probably generated from the same data. I added a link to it in my answer.
          – ilkkachu
          2 days ago














        up vote
        5
        down vote













        EDIT: Seeing ilkkachu's answer, made me test this, and the syntax he describes works, but the man page on my system (which I had checked) says




        can be either a symbolic representation of changes to make, or an octal number representing the bit pattern for the new mode bits




        which was what caused me to write the original answer (below). I guess it's a new change and that they forgot to update the man page.



        Original answer below:



        The title of your questions mentions "numerical notation", if by that you mean specifying modes as octal numbers, the answer is that you can't specify changes with that, only the new mode of the file(s).






        share|improve this answer






















        • You're right, it's not on the man page. GNU likes the info pages, so you need to read them. Or the online manual which is probably generated from the same data. I added a link to it in my answer.
          – ilkkachu
          2 days ago












        up vote
        5
        down vote










        up vote
        5
        down vote









        EDIT: Seeing ilkkachu's answer, made me test this, and the syntax he describes works, but the man page on my system (which I had checked) says




        can be either a symbolic representation of changes to make, or an octal number representing the bit pattern for the new mode bits




        which was what caused me to write the original answer (below). I guess it's a new change and that they forgot to update the man page.



        Original answer below:



        The title of your questions mentions "numerical notation", if by that you mean specifying modes as octal numbers, the answer is that you can't specify changes with that, only the new mode of the file(s).






        share|improve this answer














        EDIT: Seeing ilkkachu's answer, made me test this, and the syntax he describes works, but the man page on my system (which I had checked) says




        can be either a symbolic representation of changes to make, or an octal number representing the bit pattern for the new mode bits




        which was what caused me to write the original answer (below). I guess it's a new change and that they forgot to update the man page.



        Original answer below:



        The title of your questions mentions "numerical notation", if by that you mean specifying modes as octal numbers, the answer is that you can't specify changes with that, only the new mode of the file(s).







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited 2 days ago

























        answered Sep 9 at 21:17









        Henrik

        3,2441418




        3,2441418











        • You're right, it's not on the man page. GNU likes the info pages, so you need to read them. Or the online manual which is probably generated from the same data. I added a link to it in my answer.
          – ilkkachu
          2 days ago
















        • You're right, it's not on the man page. GNU likes the info pages, so you need to read them. Or the online manual which is probably generated from the same data. I added a link to it in my answer.
          – ilkkachu
          2 days ago















        You're right, it's not on the man page. GNU likes the info pages, so you need to read them. Or the online manual which is probably generated from the same data. I added a link to it in my answer.
        – ilkkachu
        2 days ago




        You're right, it's not on the man page. GNU likes the info pages, so you need to read them. Or the online manual which is probably generated from the same data. I added a link to it in my answer.
        – ilkkachu
        2 days ago










        up vote
        4
        down vote













        As the 2nd line of man page says:



        chmod g-w,o+r file


        $ man chmod



        CHMOD(1) User Commands CHMOD(1)

        NAME
        chmod - change file mode bits

        SYNOPSIS
        chmod [OPTION]... MODE[,MODE]... FILE...


        or the 1st line of chmod --help



        Usage: chmod [OPTION]... MODE[,MODE]... FILE...





        share|improve this answer
























          up vote
          4
          down vote













          As the 2nd line of man page says:



          chmod g-w,o+r file


          $ man chmod



          CHMOD(1) User Commands CHMOD(1)

          NAME
          chmod - change file mode bits

          SYNOPSIS
          chmod [OPTION]... MODE[,MODE]... FILE...


          or the 1st line of chmod --help



          Usage: chmod [OPTION]... MODE[,MODE]... FILE...





          share|improve this answer






















            up vote
            4
            down vote










            up vote
            4
            down vote









            As the 2nd line of man page says:



            chmod g-w,o+r file


            $ man chmod



            CHMOD(1) User Commands CHMOD(1)

            NAME
            chmod - change file mode bits

            SYNOPSIS
            chmod [OPTION]... MODE[,MODE]... FILE...


            or the 1st line of chmod --help



            Usage: chmod [OPTION]... MODE[,MODE]... FILE...





            share|improve this answer












            As the 2nd line of man page says:



            chmod g-w,o+r file


            $ man chmod



            CHMOD(1) User Commands CHMOD(1)

            NAME
            chmod - change file mode bits

            SYNOPSIS
            chmod [OPTION]... MODE[,MODE]... FILE...


            or the 1st line of chmod --help



            Usage: chmod [OPTION]... MODE[,MODE]... FILE...






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Sep 9 at 21:03









            Ipor Sircer

            9,1051920




            9,1051920




















                up vote
                3
                down vote













                Standardly, only the symbolic form allows adding and removing bits from the current permissions (though see @ilkkachu's answer if you're on a GNU system where chmod supports it with the numerical form as an extension).



                With the numerical octal form, the number you give is the new set of permission bits, regardless of what the previous value was.



                You could however get the previous value by hand and apply the modifications as a bit-logical operation.



                For instance, with zsh:



                zmodload zsh/stat
                zstat -A mode +mode -- "$file" &&
                perms=$((mode & 8#7777)) &&
                chmod -- $(((perms | 4) & ~ 8#20)) "$file"


                That's binary OR (|) with 4 to add the read permission to others and binary AND (&) with the binary NOT (~) of octal 20 to remove the write permissions to group.



                For instance, if the previous permission bits (st_mode & 0777) were 0660 (rw-rw----), 0660 | 4 would be 0664 (rw-rw-r--), and 0664 & ~ 020 would be 0644 (rw-r--r--).



                Now, I'm not sure why you'd want to do that instead of:



                chmod -- g-w,o+r "$file"





                share|improve this answer


























                  up vote
                  3
                  down vote













                  Standardly, only the symbolic form allows adding and removing bits from the current permissions (though see @ilkkachu's answer if you're on a GNU system where chmod supports it with the numerical form as an extension).



                  With the numerical octal form, the number you give is the new set of permission bits, regardless of what the previous value was.



                  You could however get the previous value by hand and apply the modifications as a bit-logical operation.



                  For instance, with zsh:



                  zmodload zsh/stat
                  zstat -A mode +mode -- "$file" &&
                  perms=$((mode & 8#7777)) &&
                  chmod -- $(((perms | 4) & ~ 8#20)) "$file"


                  That's binary OR (|) with 4 to add the read permission to others and binary AND (&) with the binary NOT (~) of octal 20 to remove the write permissions to group.



                  For instance, if the previous permission bits (st_mode & 0777) were 0660 (rw-rw----), 0660 | 4 would be 0664 (rw-rw-r--), and 0664 & ~ 020 would be 0644 (rw-r--r--).



                  Now, I'm not sure why you'd want to do that instead of:



                  chmod -- g-w,o+r "$file"





                  share|improve this answer
























                    up vote
                    3
                    down vote










                    up vote
                    3
                    down vote









                    Standardly, only the symbolic form allows adding and removing bits from the current permissions (though see @ilkkachu's answer if you're on a GNU system where chmod supports it with the numerical form as an extension).



                    With the numerical octal form, the number you give is the new set of permission bits, regardless of what the previous value was.



                    You could however get the previous value by hand and apply the modifications as a bit-logical operation.



                    For instance, with zsh:



                    zmodload zsh/stat
                    zstat -A mode +mode -- "$file" &&
                    perms=$((mode & 8#7777)) &&
                    chmod -- $(((perms | 4) & ~ 8#20)) "$file"


                    That's binary OR (|) with 4 to add the read permission to others and binary AND (&) with the binary NOT (~) of octal 20 to remove the write permissions to group.



                    For instance, if the previous permission bits (st_mode & 0777) were 0660 (rw-rw----), 0660 | 4 would be 0664 (rw-rw-r--), and 0664 & ~ 020 would be 0644 (rw-r--r--).



                    Now, I'm not sure why you'd want to do that instead of:



                    chmod -- g-w,o+r "$file"





                    share|improve this answer














                    Standardly, only the symbolic form allows adding and removing bits from the current permissions (though see @ilkkachu's answer if you're on a GNU system where chmod supports it with the numerical form as an extension).



                    With the numerical octal form, the number you give is the new set of permission bits, regardless of what the previous value was.



                    You could however get the previous value by hand and apply the modifications as a bit-logical operation.



                    For instance, with zsh:



                    zmodload zsh/stat
                    zstat -A mode +mode -- "$file" &&
                    perms=$((mode & 8#7777)) &&
                    chmod -- $(((perms | 4) & ~ 8#20)) "$file"


                    That's binary OR (|) with 4 to add the read permission to others and binary AND (&) with the binary NOT (~) of octal 20 to remove the write permissions to group.



                    For instance, if the previous permission bits (st_mode & 0777) were 0660 (rw-rw----), 0660 | 4 would be 0664 (rw-rw-r--), and 0664 & ~ 020 would be 0644 (rw-r--r--).



                    Now, I'm not sure why you'd want to do that instead of:



                    chmod -- g-w,o+r "$file"






                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited 2 days ago

























                    answered Sep 9 at 21:43









                    Stéphane Chazelas

                    283k53522859




                    283k53522859




















                        up vote
                        0
                        down vote













                        Since you didn't specify a reason for why you want to do it that way. I'll assume you don't know that it is way faster (and imho more precise) to simply set the desired mode, than to flip the flags one after another.



                        Explained in simplified terms:
                        Specify 3 numerical values for the set/unset state of all the read, write, and execute flags. For owner, group, and others all at once.



                        To simplify, I'll stick to 3 digits.
                        But you should look at the rest of the flags too when you get used to this way of doing it.



                        To simplify even more:
                        These 3 values are separate positional values, and not a three digit number. The first one sets the permissions for owner, the next one sets the permissions for group, and the third, sets the permissions for everyone else (others).



                        Setting the flags:
                        Now. Determining what each digit means is where some people get confused, but it's really simple when you first learn how it's done.



                        Here are the flag-values:



                        • 1=execute

                        • 2=write

                        • 4=read

                        Now, you simply do one position at a time, and add (sum) the desired flag-values together. If you want to set read and execute: 4+1=5. If you want read and write but not execute: 4+2=6.



                        Examples




                        | ### | Owner | Group | Others |
                        | --- | --- | --- | --- |
                        | 755 | RWX | R-X | R-X |
                        | 644 | RW- | R-- | R-- |


                        Extra info and more examples can be seen here:
                        https://linux.die.net/Linux-CLI/file-permissions.html



                        So if you want group and others to only have read permission, but owner should have read and write, you simply do chmod 644 FILENAME



                        Here's a great tutorial: Understanding Linux File Permissions



                        One last tip:
                        Remember that users need execute permission for directories to list the content.






                        share|improve this answer








                        New contributor




                        svin83 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                        Check out our Code of Conduct.





















                          up vote
                          0
                          down vote













                          Since you didn't specify a reason for why you want to do it that way. I'll assume you don't know that it is way faster (and imho more precise) to simply set the desired mode, than to flip the flags one after another.



                          Explained in simplified terms:
                          Specify 3 numerical values for the set/unset state of all the read, write, and execute flags. For owner, group, and others all at once.



                          To simplify, I'll stick to 3 digits.
                          But you should look at the rest of the flags too when you get used to this way of doing it.



                          To simplify even more:
                          These 3 values are separate positional values, and not a three digit number. The first one sets the permissions for owner, the next one sets the permissions for group, and the third, sets the permissions for everyone else (others).



                          Setting the flags:
                          Now. Determining what each digit means is where some people get confused, but it's really simple when you first learn how it's done.



                          Here are the flag-values:



                          • 1=execute

                          • 2=write

                          • 4=read

                          Now, you simply do one position at a time, and add (sum) the desired flag-values together. If you want to set read and execute: 4+1=5. If you want read and write but not execute: 4+2=6.



                          Examples




                          | ### | Owner | Group | Others |
                          | --- | --- | --- | --- |
                          | 755 | RWX | R-X | R-X |
                          | 644 | RW- | R-- | R-- |


                          Extra info and more examples can be seen here:
                          https://linux.die.net/Linux-CLI/file-permissions.html



                          So if you want group and others to only have read permission, but owner should have read and write, you simply do chmod 644 FILENAME



                          Here's a great tutorial: Understanding Linux File Permissions



                          One last tip:
                          Remember that users need execute permission for directories to list the content.






                          share|improve this answer








                          New contributor




                          svin83 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.



















                            up vote
                            0
                            down vote










                            up vote
                            0
                            down vote









                            Since you didn't specify a reason for why you want to do it that way. I'll assume you don't know that it is way faster (and imho more precise) to simply set the desired mode, than to flip the flags one after another.



                            Explained in simplified terms:
                            Specify 3 numerical values for the set/unset state of all the read, write, and execute flags. For owner, group, and others all at once.



                            To simplify, I'll stick to 3 digits.
                            But you should look at the rest of the flags too when you get used to this way of doing it.



                            To simplify even more:
                            These 3 values are separate positional values, and not a three digit number. The first one sets the permissions for owner, the next one sets the permissions for group, and the third, sets the permissions for everyone else (others).



                            Setting the flags:
                            Now. Determining what each digit means is where some people get confused, but it's really simple when you first learn how it's done.



                            Here are the flag-values:



                            • 1=execute

                            • 2=write

                            • 4=read

                            Now, you simply do one position at a time, and add (sum) the desired flag-values together. If you want to set read and execute: 4+1=5. If you want read and write but not execute: 4+2=6.



                            Examples




                            | ### | Owner | Group | Others |
                            | --- | --- | --- | --- |
                            | 755 | RWX | R-X | R-X |
                            | 644 | RW- | R-- | R-- |


                            Extra info and more examples can be seen here:
                            https://linux.die.net/Linux-CLI/file-permissions.html



                            So if you want group and others to only have read permission, but owner should have read and write, you simply do chmod 644 FILENAME



                            Here's a great tutorial: Understanding Linux File Permissions



                            One last tip:
                            Remember that users need execute permission for directories to list the content.






                            share|improve this answer








                            New contributor




                            svin83 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                            Check out our Code of Conduct.









                            Since you didn't specify a reason for why you want to do it that way. I'll assume you don't know that it is way faster (and imho more precise) to simply set the desired mode, than to flip the flags one after another.



                            Explained in simplified terms:
                            Specify 3 numerical values for the set/unset state of all the read, write, and execute flags. For owner, group, and others all at once.



                            To simplify, I'll stick to 3 digits.
                            But you should look at the rest of the flags too when you get used to this way of doing it.



                            To simplify even more:
                            These 3 values are separate positional values, and not a three digit number. The first one sets the permissions for owner, the next one sets the permissions for group, and the third, sets the permissions for everyone else (others).



                            Setting the flags:
                            Now. Determining what each digit means is where some people get confused, but it's really simple when you first learn how it's done.



                            Here are the flag-values:



                            • 1=execute

                            • 2=write

                            • 4=read

                            Now, you simply do one position at a time, and add (sum) the desired flag-values together. If you want to set read and execute: 4+1=5. If you want read and write but not execute: 4+2=6.



                            Examples




                            | ### | Owner | Group | Others |
                            | --- | --- | --- | --- |
                            | 755 | RWX | R-X | R-X |
                            | 644 | RW- | R-- | R-- |


                            Extra info and more examples can be seen here:
                            https://linux.die.net/Linux-CLI/file-permissions.html



                            So if you want group and others to only have read permission, but owner should have read and write, you simply do chmod 644 FILENAME



                            Here's a great tutorial: Understanding Linux File Permissions



                            One last tip:
                            Remember that users need execute permission for directories to list the content.







                            share|improve this answer








                            New contributor




                            svin83 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                            Check out our Code of Conduct.









                            share|improve this answer



                            share|improve this answer






                            New contributor




                            svin83 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                            Check out our Code of Conduct.









                            answered 2 days ago









                            svin83

                            1091




                            1091




                            New contributor




                            svin83 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                            Check out our Code of Conduct.





                            New contributor





                            svin83 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                            Check out our Code of Conduct.






                            svin83 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                            Check out our Code of Conduct.




















                                Zanders2001 is a new contributor. Be nice, and check out our Code of Conduct.









                                 

                                draft saved


                                draft discarded


















                                Zanders2001 is a new contributor. Be nice, and check out our Code of Conduct.












                                Zanders2001 is a new contributor. Be nice, and check out our Code of Conduct.











                                Zanders2001 is a new contributor. Be nice, and check out our Code of Conduct.













                                 


                                draft saved


                                draft discarded














                                StackExchange.ready(
                                function ()
                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f467925%2fremoving-and-adding-permission-using-numerical-notation-on-the-same-line%23new-answer', 'question_page');

                                );

                                Post as a guest













































































                                Comments

                                Popular posts from this blog

                                What does second last employer means? [closed]

                                List of Gilmore Girls characters

                                Confectionery