What permissions must be set on a directory to allow one to append data to a file in that directory, but not...











up vote
-1
down vote

favorite












"What permissions must be set on a directory to allow one to append data to a file in that directory, but not to remove that file?"



From my understanding, you need the 'w' write permission to append data to a file, but that will also give you the ability to remove the file but the question is asking for the permissions that should be set for one to be able to append data to a file BUT not remove it.










share|improve this question









New contributor




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
























    up vote
    -1
    down vote

    favorite












    "What permissions must be set on a directory to allow one to append data to a file in that directory, but not to remove that file?"



    From my understanding, you need the 'w' write permission to append data to a file, but that will also give you the ability to remove the file but the question is asking for the permissions that should be set for one to be able to append data to a file BUT not remove it.










    share|improve this question









    New contributor




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






















      up vote
      -1
      down vote

      favorite









      up vote
      -1
      down vote

      favorite











      "What permissions must be set on a directory to allow one to append data to a file in that directory, but not to remove that file?"



      From my understanding, you need the 'w' write permission to append data to a file, but that will also give you the ability to remove the file but the question is asking for the permissions that should be set for one to be able to append data to a file BUT not remove it.










      share|improve this question









      New contributor




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











      "What permissions must be set on a directory to allow one to append data to a file in that directory, but not to remove that file?"



      From my understanding, you need the 'w' write permission to append data to a file, but that will also give you the ability to remove the file but the question is asking for the permissions that should be set for one to be able to append data to a file BUT not remove it.







      linux






      share|improve this question









      New contributor




      Mandingo 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




      Mandingo 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 Nov 23 at 11:10









      Rui F Ribeiro

      38.3k1475127




      38.3k1475127






      New contributor




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









      asked Nov 23 at 4:21









      Mandingo

      225




      225




      New contributor




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





      New contributor





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






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






















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          3
          down vote



          accepted










          Appending data to a file requires write permission on the file itself. Removing a file requires write permission on the directory containing a file.



          For example, I have a directory called testdir, for which I have removed write permissions:



          [haxiel@testvm1 ~]$ ls -ld testdir/
          dr-xr-xr-x. 2 haxiel haxiel 26 Nov 23 10:09 testdir/


          Inside the directory, I had created a file called testfile.txt (this was done before removing the write permission on the directory).



          [haxiel@testvm1 testdir]$ ls -l testfile.txt
          -rw-rw-r--. 1 haxiel haxiel 12 Nov 23 10:11 testfile.txt


          Now, I am able to append data to the file, since I have write permission on it:



          [haxiel@testvm1 testdir]$ echo "Line1" >> testfile.txt
          [haxiel@testvm1 testdir]$ echo "Line2" >> testfile.txt
          [haxiel@testvm1 testdir]$ cat testfile.txt
          Line1
          Line2


          But I cannot remove the file since I do not have write permissions on its parent directory.



          [haxiel@testvm1 testdir]$ rm testfile.txt
          rm: cannot remove ‘testfile.txt’: Permission denied




          You can look at this question for more details on directory permissions: Execute vs Read bit. How do directory permissions in Linux work?






          share|improve this answer

















          • 1




            Yes, but one could still make the file empty. Thus sercumventing the whole reason for the question. All the data would still be gone. @Haxiel
            – Michael Prokopec
            Nov 23 at 5:11




















          up vote
          1
          down vote













          The Directory has nothing to do with the files permissions. The file, if it can be written too, can also be deleted. You could try ACLs, like here: How to give permissions to read write but not delete the file , but that is easily sercumvented.



          Here is a explination of file permissions:



          (rwx------)  This area is for owner.
          (---rwx---) This area is for group owner.
          (------rwx) This area is for others.
          (-rwx------) The preceding - indicates a directory.

          Value | Meaning
          |
          ==========================================================================================================================================================================================================
          |
          777 (rwxrwxrwx) | No restrictions on permissions. Anybody may do anything. Generally not a desirable setting.

          755 (rwxr-xr-x) | The file's owner may read, write, and execute the file. All others may read and execute the file. This setting is common for programs that are used by all users.

          700 (rwx------) | The file's owner may read, write, and execute the file. Nobody else has any rights. This setting is useful for programs that only the owner may use and must be kept private from others.

          666 (rw-rw-rw-) | All users may read and write the file.

          644 (rw-r--r--) | The owner may read and write a file, while all others may only read the file. A common setting for data files that everybody may read, but only the owner may change.

          600 (rw-------) | The owner may read and write a file. All others have no rights. A common setting for data files that the owner wants to keep private.





          share|improve this answer








          New contributor




          Michael Prokopec 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: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });






            Mandingo 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%2f483585%2fwhat-permissions-must-be-set-on-a-directory-to-allow-one-to-append-data-to-a-fil%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            3
            down vote



            accepted










            Appending data to a file requires write permission on the file itself. Removing a file requires write permission on the directory containing a file.



            For example, I have a directory called testdir, for which I have removed write permissions:



            [haxiel@testvm1 ~]$ ls -ld testdir/
            dr-xr-xr-x. 2 haxiel haxiel 26 Nov 23 10:09 testdir/


            Inside the directory, I had created a file called testfile.txt (this was done before removing the write permission on the directory).



            [haxiel@testvm1 testdir]$ ls -l testfile.txt
            -rw-rw-r--. 1 haxiel haxiel 12 Nov 23 10:11 testfile.txt


            Now, I am able to append data to the file, since I have write permission on it:



            [haxiel@testvm1 testdir]$ echo "Line1" >> testfile.txt
            [haxiel@testvm1 testdir]$ echo "Line2" >> testfile.txt
            [haxiel@testvm1 testdir]$ cat testfile.txt
            Line1
            Line2


            But I cannot remove the file since I do not have write permissions on its parent directory.



            [haxiel@testvm1 testdir]$ rm testfile.txt
            rm: cannot remove ‘testfile.txt’: Permission denied




            You can look at this question for more details on directory permissions: Execute vs Read bit. How do directory permissions in Linux work?






            share|improve this answer

















            • 1




              Yes, but one could still make the file empty. Thus sercumventing the whole reason for the question. All the data would still be gone. @Haxiel
              – Michael Prokopec
              Nov 23 at 5:11

















            up vote
            3
            down vote



            accepted










            Appending data to a file requires write permission on the file itself. Removing a file requires write permission on the directory containing a file.



            For example, I have a directory called testdir, for which I have removed write permissions:



            [haxiel@testvm1 ~]$ ls -ld testdir/
            dr-xr-xr-x. 2 haxiel haxiel 26 Nov 23 10:09 testdir/


            Inside the directory, I had created a file called testfile.txt (this was done before removing the write permission on the directory).



            [haxiel@testvm1 testdir]$ ls -l testfile.txt
            -rw-rw-r--. 1 haxiel haxiel 12 Nov 23 10:11 testfile.txt


            Now, I am able to append data to the file, since I have write permission on it:



            [haxiel@testvm1 testdir]$ echo "Line1" >> testfile.txt
            [haxiel@testvm1 testdir]$ echo "Line2" >> testfile.txt
            [haxiel@testvm1 testdir]$ cat testfile.txt
            Line1
            Line2


            But I cannot remove the file since I do not have write permissions on its parent directory.



            [haxiel@testvm1 testdir]$ rm testfile.txt
            rm: cannot remove ‘testfile.txt’: Permission denied




            You can look at this question for more details on directory permissions: Execute vs Read bit. How do directory permissions in Linux work?






            share|improve this answer

















            • 1




              Yes, but one could still make the file empty. Thus sercumventing the whole reason for the question. All the data would still be gone. @Haxiel
              – Michael Prokopec
              Nov 23 at 5:11















            up vote
            3
            down vote



            accepted







            up vote
            3
            down vote



            accepted






            Appending data to a file requires write permission on the file itself. Removing a file requires write permission on the directory containing a file.



            For example, I have a directory called testdir, for which I have removed write permissions:



            [haxiel@testvm1 ~]$ ls -ld testdir/
            dr-xr-xr-x. 2 haxiel haxiel 26 Nov 23 10:09 testdir/


            Inside the directory, I had created a file called testfile.txt (this was done before removing the write permission on the directory).



            [haxiel@testvm1 testdir]$ ls -l testfile.txt
            -rw-rw-r--. 1 haxiel haxiel 12 Nov 23 10:11 testfile.txt


            Now, I am able to append data to the file, since I have write permission on it:



            [haxiel@testvm1 testdir]$ echo "Line1" >> testfile.txt
            [haxiel@testvm1 testdir]$ echo "Line2" >> testfile.txt
            [haxiel@testvm1 testdir]$ cat testfile.txt
            Line1
            Line2


            But I cannot remove the file since I do not have write permissions on its parent directory.



            [haxiel@testvm1 testdir]$ rm testfile.txt
            rm: cannot remove ‘testfile.txt’: Permission denied




            You can look at this question for more details on directory permissions: Execute vs Read bit. How do directory permissions in Linux work?






            share|improve this answer












            Appending data to a file requires write permission on the file itself. Removing a file requires write permission on the directory containing a file.



            For example, I have a directory called testdir, for which I have removed write permissions:



            [haxiel@testvm1 ~]$ ls -ld testdir/
            dr-xr-xr-x. 2 haxiel haxiel 26 Nov 23 10:09 testdir/


            Inside the directory, I had created a file called testfile.txt (this was done before removing the write permission on the directory).



            [haxiel@testvm1 testdir]$ ls -l testfile.txt
            -rw-rw-r--. 1 haxiel haxiel 12 Nov 23 10:11 testfile.txt


            Now, I am able to append data to the file, since I have write permission on it:



            [haxiel@testvm1 testdir]$ echo "Line1" >> testfile.txt
            [haxiel@testvm1 testdir]$ echo "Line2" >> testfile.txt
            [haxiel@testvm1 testdir]$ cat testfile.txt
            Line1
            Line2


            But I cannot remove the file since I do not have write permissions on its parent directory.



            [haxiel@testvm1 testdir]$ rm testfile.txt
            rm: cannot remove ‘testfile.txt’: Permission denied




            You can look at this question for more details on directory permissions: Execute vs Read bit. How do directory permissions in Linux work?







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Nov 23 at 4:47









            Haxiel

            51138




            51138








            • 1




              Yes, but one could still make the file empty. Thus sercumventing the whole reason for the question. All the data would still be gone. @Haxiel
              – Michael Prokopec
              Nov 23 at 5:11
















            • 1




              Yes, but one could still make the file empty. Thus sercumventing the whole reason for the question. All the data would still be gone. @Haxiel
              – Michael Prokopec
              Nov 23 at 5:11










            1




            1




            Yes, but one could still make the file empty. Thus sercumventing the whole reason for the question. All the data would still be gone. @Haxiel
            – Michael Prokopec
            Nov 23 at 5:11






            Yes, but one could still make the file empty. Thus sercumventing the whole reason for the question. All the data would still be gone. @Haxiel
            – Michael Prokopec
            Nov 23 at 5:11














            up vote
            1
            down vote













            The Directory has nothing to do with the files permissions. The file, if it can be written too, can also be deleted. You could try ACLs, like here: How to give permissions to read write but not delete the file , but that is easily sercumvented.



            Here is a explination of file permissions:



            (rwx------)  This area is for owner.
            (---rwx---) This area is for group owner.
            (------rwx) This area is for others.
            (-rwx------) The preceding - indicates a directory.

            Value | Meaning
            |
            ==========================================================================================================================================================================================================
            |
            777 (rwxrwxrwx) | No restrictions on permissions. Anybody may do anything. Generally not a desirable setting.

            755 (rwxr-xr-x) | The file's owner may read, write, and execute the file. All others may read and execute the file. This setting is common for programs that are used by all users.

            700 (rwx------) | The file's owner may read, write, and execute the file. Nobody else has any rights. This setting is useful for programs that only the owner may use and must be kept private from others.

            666 (rw-rw-rw-) | All users may read and write the file.

            644 (rw-r--r--) | The owner may read and write a file, while all others may only read the file. A common setting for data files that everybody may read, but only the owner may change.

            600 (rw-------) | The owner may read and write a file. All others have no rights. A common setting for data files that the owner wants to keep private.





            share|improve this answer








            New contributor




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






















              up vote
              1
              down vote













              The Directory has nothing to do with the files permissions. The file, if it can be written too, can also be deleted. You could try ACLs, like here: How to give permissions to read write but not delete the file , but that is easily sercumvented.



              Here is a explination of file permissions:



              (rwx------)  This area is for owner.
              (---rwx---) This area is for group owner.
              (------rwx) This area is for others.
              (-rwx------) The preceding - indicates a directory.

              Value | Meaning
              |
              ==========================================================================================================================================================================================================
              |
              777 (rwxrwxrwx) | No restrictions on permissions. Anybody may do anything. Generally not a desirable setting.

              755 (rwxr-xr-x) | The file's owner may read, write, and execute the file. All others may read and execute the file. This setting is common for programs that are used by all users.

              700 (rwx------) | The file's owner may read, write, and execute the file. Nobody else has any rights. This setting is useful for programs that only the owner may use and must be kept private from others.

              666 (rw-rw-rw-) | All users may read and write the file.

              644 (rw-r--r--) | The owner may read and write a file, while all others may only read the file. A common setting for data files that everybody may read, but only the owner may change.

              600 (rw-------) | The owner may read and write a file. All others have no rights. A common setting for data files that the owner wants to keep private.





              share|improve this answer








              New contributor




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




















                up vote
                1
                down vote










                up vote
                1
                down vote









                The Directory has nothing to do with the files permissions. The file, if it can be written too, can also be deleted. You could try ACLs, like here: How to give permissions to read write but not delete the file , but that is easily sercumvented.



                Here is a explination of file permissions:



                (rwx------)  This area is for owner.
                (---rwx---) This area is for group owner.
                (------rwx) This area is for others.
                (-rwx------) The preceding - indicates a directory.

                Value | Meaning
                |
                ==========================================================================================================================================================================================================
                |
                777 (rwxrwxrwx) | No restrictions on permissions. Anybody may do anything. Generally not a desirable setting.

                755 (rwxr-xr-x) | The file's owner may read, write, and execute the file. All others may read and execute the file. This setting is common for programs that are used by all users.

                700 (rwx------) | The file's owner may read, write, and execute the file. Nobody else has any rights. This setting is useful for programs that only the owner may use and must be kept private from others.

                666 (rw-rw-rw-) | All users may read and write the file.

                644 (rw-r--r--) | The owner may read and write a file, while all others may only read the file. A common setting for data files that everybody may read, but only the owner may change.

                600 (rw-------) | The owner may read and write a file. All others have no rights. A common setting for data files that the owner wants to keep private.





                share|improve this answer








                New contributor




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









                The Directory has nothing to do with the files permissions. The file, if it can be written too, can also be deleted. You could try ACLs, like here: How to give permissions to read write but not delete the file , but that is easily sercumvented.



                Here is a explination of file permissions:



                (rwx------)  This area is for owner.
                (---rwx---) This area is for group owner.
                (------rwx) This area is for others.
                (-rwx------) The preceding - indicates a directory.

                Value | Meaning
                |
                ==========================================================================================================================================================================================================
                |
                777 (rwxrwxrwx) | No restrictions on permissions. Anybody may do anything. Generally not a desirable setting.

                755 (rwxr-xr-x) | The file's owner may read, write, and execute the file. All others may read and execute the file. This setting is common for programs that are used by all users.

                700 (rwx------) | The file's owner may read, write, and execute the file. Nobody else has any rights. This setting is useful for programs that only the owner may use and must be kept private from others.

                666 (rw-rw-rw-) | All users may read and write the file.

                644 (rw-r--r--) | The owner may read and write a file, while all others may only read the file. A common setting for data files that everybody may read, but only the owner may change.

                600 (rw-------) | The owner may read and write a file. All others have no rights. A common setting for data files that the owner wants to keep private.






                share|improve this answer








                New contributor




                Michael Prokopec 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




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









                answered Nov 23 at 5:06









                Michael Prokopec

                62115




                62115




                New contributor




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





                New contributor





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






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






















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










                    draft saved

                    draft discarded


















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













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












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
















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


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.





                    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%2funix.stackexchange.com%2fquestions%2f483585%2fwhat-permissions-must-be-set-on-a-directory-to-allow-one-to-append-data-to-a-fil%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

                    List directoties down one level, excluding some named directories and files

                    list processes belonging to a network namespace

                    list systemd RuntimeDirectory mounts