Why can 'Others' read files by default in Ubuntu?











up vote
5
down vote

favorite












I am trying to figure out why when creating new files and directories in, let's say, the Documents folder, they get assigned, by default, the following permissions:



-rw-rw-r-- 1 hello world    0 Nov 19 12:17 'New Empty File'
drwxrwxr-x 2 hello world 4.0K Nov 19 12:16 'New Folder'/


Shouldn't 'Others' have no access to my files? From what I've read, Ubuntu is by default pretty secure. However, nowhere could I find a rationalization for this behavior. Would appreciate an answer :)










share|improve this question







New contributor




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
























    up vote
    5
    down vote

    favorite












    I am trying to figure out why when creating new files and directories in, let's say, the Documents folder, they get assigned, by default, the following permissions:



    -rw-rw-r-- 1 hello world    0 Nov 19 12:17 'New Empty File'
    drwxrwxr-x 2 hello world 4.0K Nov 19 12:16 'New Folder'/


    Shouldn't 'Others' have no access to my files? From what I've read, Ubuntu is by default pretty secure. However, nowhere could I find a rationalization for this behavior. Would appreciate an answer :)










    share|improve this question







    New contributor




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






















      up vote
      5
      down vote

      favorite









      up vote
      5
      down vote

      favorite











      I am trying to figure out why when creating new files and directories in, let's say, the Documents folder, they get assigned, by default, the following permissions:



      -rw-rw-r-- 1 hello world    0 Nov 19 12:17 'New Empty File'
      drwxrwxr-x 2 hello world 4.0K Nov 19 12:16 'New Folder'/


      Shouldn't 'Others' have no access to my files? From what I've read, Ubuntu is by default pretty secure. However, nowhere could I find a rationalization for this behavior. Would appreciate an answer :)










      share|improve this question







      New contributor




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











      I am trying to figure out why when creating new files and directories in, let's say, the Documents folder, they get assigned, by default, the following permissions:



      -rw-rw-r-- 1 hello world    0 Nov 19 12:17 'New Empty File'
      drwxrwxr-x 2 hello world 4.0K Nov 19 12:16 'New Folder'/


      Shouldn't 'Others' have no access to my files? From what I've read, Ubuntu is by default pretty secure. However, nowhere could I find a rationalization for this behavior. Would appreciate an answer :)







      linux ubuntu






      share|improve this question







      New contributor




      wombat trash 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




      wombat trash 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






      New contributor




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









      asked yesterday









      wombat trash

      304




      304




      New contributor




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





      New contributor





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






      wombat trash 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
          13
          down vote



          accepted










          The permissions model of Linux means that, even if you are the only user of your computer, you're not the only user on the system. Many services will create their own user account to run under - for example, Apache will usually run under its own dedicated account.



          What you will also notice is that your home folder is usually only accessible to your own account - i.e. permissions 700 or drwx------. That means that only you can get at your home folder, even if subfolders within that folder have full access.



          This combination provides a useful balance. The default permissions allow service accounts to read any files on the system that they might need to, but they can't change anything. Any files which are personal to you should be in your home folder, so a rogue service won't be able to access them.



          You might find the Filesystem Hierarchy Standard a useful read. This outlines the generally expected permissions and functions for Unix/Linux systems, and most distributions will abide by this.






          share|improve this answer










          New contributor




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














          • 2




            For me, on Xubuntu 18.04, /home/<home folder> has drwxr-xr-x permissions. Can't then an attacker try to make a user in my group to subvert this rationale?
            – wombat trash
            yesterday








          • 11




            If an attacker has a way to create a user "in your group" you have already lost, cause if he can do that, he can just as easily make one in the "root" group / with root rights.
            – Florian Bach
            yesterday






          • 2




            It might be worth adding a little about umask and how the default permissions for new files can be changed, and the caveats of doing that
            – Dezza
            yesterday






          • 1




            @FlorianBach drwxr-xr-x permissions mean any other users on the system can read the files, not just users in your group. This includes other people with non-admin access user accounts on the system.
            – Macil
            17 hours ago










          • As @Macil points out, your home directory is mode 755, NOT 700, on Ubuntu. Anybody who wants to can list and traverse it. While certain subdirectories ("Documents", perhaps) might be 700, files and directories created in ~ are world-readable by default. Since quite a few programs make the same error that you made of assuming the home directory is private, they don't change the mode on their own files and end up emitting potentially-sensitive world-readable data. Ubuntu sucks.
            – CBHacking
            16 hours ago


















          up vote
          1
          down vote













          When you create new files and directories, the initial permissions are controlled by your umask setting. The application creating the item specifies the maximum permissions (typically rwxrwxrwx for directories and executable files, rw-rw-rw- for data files), and then the permissions in umask are subtracted from this.



          So if you want more restrictive permissions, you should set your umask to remove the permissions you don't want to grant. The permissions you show come from having umask 002, so it just disables other=write. If you want to disable other=read/execute as well, you should used:



          umask 007


          Traditionally, the default umask 002 comes from the assumption that all the users on a particular system would be a cooperating community (e.g. programmers in the same department of an organization), so there's little reason to prevent other users from reading your files in general. If you have specific files that are more private, you'd give them more restrictive permissions. If the above assumption is inappropriate for the users of your system, you should use a different default umask in the shell startup scripts.






          share|improve this answer





















            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "162"
            };
            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
            },
            noCode: true, onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });






            wombat trash 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%2fsecurity.stackexchange.com%2fquestions%2f197976%2fwhy-can-others-read-files-by-default-in-ubuntu%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
            13
            down vote



            accepted










            The permissions model of Linux means that, even if you are the only user of your computer, you're not the only user on the system. Many services will create their own user account to run under - for example, Apache will usually run under its own dedicated account.



            What you will also notice is that your home folder is usually only accessible to your own account - i.e. permissions 700 or drwx------. That means that only you can get at your home folder, even if subfolders within that folder have full access.



            This combination provides a useful balance. The default permissions allow service accounts to read any files on the system that they might need to, but they can't change anything. Any files which are personal to you should be in your home folder, so a rogue service won't be able to access them.



            You might find the Filesystem Hierarchy Standard a useful read. This outlines the generally expected permissions and functions for Unix/Linux systems, and most distributions will abide by this.






            share|improve this answer










            New contributor




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














            • 2




              For me, on Xubuntu 18.04, /home/<home folder> has drwxr-xr-x permissions. Can't then an attacker try to make a user in my group to subvert this rationale?
              – wombat trash
              yesterday








            • 11




              If an attacker has a way to create a user "in your group" you have already lost, cause if he can do that, he can just as easily make one in the "root" group / with root rights.
              – Florian Bach
              yesterday






            • 2




              It might be worth adding a little about umask and how the default permissions for new files can be changed, and the caveats of doing that
              – Dezza
              yesterday






            • 1




              @FlorianBach drwxr-xr-x permissions mean any other users on the system can read the files, not just users in your group. This includes other people with non-admin access user accounts on the system.
              – Macil
              17 hours ago










            • As @Macil points out, your home directory is mode 755, NOT 700, on Ubuntu. Anybody who wants to can list and traverse it. While certain subdirectories ("Documents", perhaps) might be 700, files and directories created in ~ are world-readable by default. Since quite a few programs make the same error that you made of assuming the home directory is private, they don't change the mode on their own files and end up emitting potentially-sensitive world-readable data. Ubuntu sucks.
              – CBHacking
              16 hours ago















            up vote
            13
            down vote



            accepted










            The permissions model of Linux means that, even if you are the only user of your computer, you're not the only user on the system. Many services will create their own user account to run under - for example, Apache will usually run under its own dedicated account.



            What you will also notice is that your home folder is usually only accessible to your own account - i.e. permissions 700 or drwx------. That means that only you can get at your home folder, even if subfolders within that folder have full access.



            This combination provides a useful balance. The default permissions allow service accounts to read any files on the system that they might need to, but they can't change anything. Any files which are personal to you should be in your home folder, so a rogue service won't be able to access them.



            You might find the Filesystem Hierarchy Standard a useful read. This outlines the generally expected permissions and functions for Unix/Linux systems, and most distributions will abide by this.






            share|improve this answer










            New contributor




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














            • 2




              For me, on Xubuntu 18.04, /home/<home folder> has drwxr-xr-x permissions. Can't then an attacker try to make a user in my group to subvert this rationale?
              – wombat trash
              yesterday








            • 11




              If an attacker has a way to create a user "in your group" you have already lost, cause if he can do that, he can just as easily make one in the "root" group / with root rights.
              – Florian Bach
              yesterday






            • 2




              It might be worth adding a little about umask and how the default permissions for new files can be changed, and the caveats of doing that
              – Dezza
              yesterday






            • 1




              @FlorianBach drwxr-xr-x permissions mean any other users on the system can read the files, not just users in your group. This includes other people with non-admin access user accounts on the system.
              – Macil
              17 hours ago










            • As @Macil points out, your home directory is mode 755, NOT 700, on Ubuntu. Anybody who wants to can list and traverse it. While certain subdirectories ("Documents", perhaps) might be 700, files and directories created in ~ are world-readable by default. Since quite a few programs make the same error that you made of assuming the home directory is private, they don't change the mode on their own files and end up emitting potentially-sensitive world-readable data. Ubuntu sucks.
              – CBHacking
              16 hours ago













            up vote
            13
            down vote



            accepted







            up vote
            13
            down vote



            accepted






            The permissions model of Linux means that, even if you are the only user of your computer, you're not the only user on the system. Many services will create their own user account to run under - for example, Apache will usually run under its own dedicated account.



            What you will also notice is that your home folder is usually only accessible to your own account - i.e. permissions 700 or drwx------. That means that only you can get at your home folder, even if subfolders within that folder have full access.



            This combination provides a useful balance. The default permissions allow service accounts to read any files on the system that they might need to, but they can't change anything. Any files which are personal to you should be in your home folder, so a rogue service won't be able to access them.



            You might find the Filesystem Hierarchy Standard a useful read. This outlines the generally expected permissions and functions for Unix/Linux systems, and most distributions will abide by this.






            share|improve this answer










            New contributor




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









            The permissions model of Linux means that, even if you are the only user of your computer, you're not the only user on the system. Many services will create their own user account to run under - for example, Apache will usually run under its own dedicated account.



            What you will also notice is that your home folder is usually only accessible to your own account - i.e. permissions 700 or drwx------. That means that only you can get at your home folder, even if subfolders within that folder have full access.



            This combination provides a useful balance. The default permissions allow service accounts to read any files on the system that they might need to, but they can't change anything. Any files which are personal to you should be in your home folder, so a rogue service won't be able to access them.



            You might find the Filesystem Hierarchy Standard a useful read. This outlines the generally expected permissions and functions for Unix/Linux systems, and most distributions will abide by this.







            share|improve this answer










            New contributor




            timbstoke 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








            edited 21 hours ago









            wombat trash

            304




            304






            New contributor




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









            answered yesterday









            timbstoke

            24622




            24622




            New contributor




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





            New contributor





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






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








            • 2




              For me, on Xubuntu 18.04, /home/<home folder> has drwxr-xr-x permissions. Can't then an attacker try to make a user in my group to subvert this rationale?
              – wombat trash
              yesterday








            • 11




              If an attacker has a way to create a user "in your group" you have already lost, cause if he can do that, he can just as easily make one in the "root" group / with root rights.
              – Florian Bach
              yesterday






            • 2




              It might be worth adding a little about umask and how the default permissions for new files can be changed, and the caveats of doing that
              – Dezza
              yesterday






            • 1




              @FlorianBach drwxr-xr-x permissions mean any other users on the system can read the files, not just users in your group. This includes other people with non-admin access user accounts on the system.
              – Macil
              17 hours ago










            • As @Macil points out, your home directory is mode 755, NOT 700, on Ubuntu. Anybody who wants to can list and traverse it. While certain subdirectories ("Documents", perhaps) might be 700, files and directories created in ~ are world-readable by default. Since quite a few programs make the same error that you made of assuming the home directory is private, they don't change the mode on their own files and end up emitting potentially-sensitive world-readable data. Ubuntu sucks.
              – CBHacking
              16 hours ago














            • 2




              For me, on Xubuntu 18.04, /home/<home folder> has drwxr-xr-x permissions. Can't then an attacker try to make a user in my group to subvert this rationale?
              – wombat trash
              yesterday








            • 11




              If an attacker has a way to create a user "in your group" you have already lost, cause if he can do that, he can just as easily make one in the "root" group / with root rights.
              – Florian Bach
              yesterday






            • 2




              It might be worth adding a little about umask and how the default permissions for new files can be changed, and the caveats of doing that
              – Dezza
              yesterday






            • 1




              @FlorianBach drwxr-xr-x permissions mean any other users on the system can read the files, not just users in your group. This includes other people with non-admin access user accounts on the system.
              – Macil
              17 hours ago










            • As @Macil points out, your home directory is mode 755, NOT 700, on Ubuntu. Anybody who wants to can list and traverse it. While certain subdirectories ("Documents", perhaps) might be 700, files and directories created in ~ are world-readable by default. Since quite a few programs make the same error that you made of assuming the home directory is private, they don't change the mode on their own files and end up emitting potentially-sensitive world-readable data. Ubuntu sucks.
              – CBHacking
              16 hours ago








            2




            2




            For me, on Xubuntu 18.04, /home/<home folder> has drwxr-xr-x permissions. Can't then an attacker try to make a user in my group to subvert this rationale?
            – wombat trash
            yesterday






            For me, on Xubuntu 18.04, /home/<home folder> has drwxr-xr-x permissions. Can't then an attacker try to make a user in my group to subvert this rationale?
            – wombat trash
            yesterday






            11




            11




            If an attacker has a way to create a user "in your group" you have already lost, cause if he can do that, he can just as easily make one in the "root" group / with root rights.
            – Florian Bach
            yesterday




            If an attacker has a way to create a user "in your group" you have already lost, cause if he can do that, he can just as easily make one in the "root" group / with root rights.
            – Florian Bach
            yesterday




            2




            2




            It might be worth adding a little about umask and how the default permissions for new files can be changed, and the caveats of doing that
            – Dezza
            yesterday




            It might be worth adding a little about umask and how the default permissions for new files can be changed, and the caveats of doing that
            – Dezza
            yesterday




            1




            1




            @FlorianBach drwxr-xr-x permissions mean any other users on the system can read the files, not just users in your group. This includes other people with non-admin access user accounts on the system.
            – Macil
            17 hours ago




            @FlorianBach drwxr-xr-x permissions mean any other users on the system can read the files, not just users in your group. This includes other people with non-admin access user accounts on the system.
            – Macil
            17 hours ago












            As @Macil points out, your home directory is mode 755, NOT 700, on Ubuntu. Anybody who wants to can list and traverse it. While certain subdirectories ("Documents", perhaps) might be 700, files and directories created in ~ are world-readable by default. Since quite a few programs make the same error that you made of assuming the home directory is private, they don't change the mode on their own files and end up emitting potentially-sensitive world-readable data. Ubuntu sucks.
            – CBHacking
            16 hours ago




            As @Macil points out, your home directory is mode 755, NOT 700, on Ubuntu. Anybody who wants to can list and traverse it. While certain subdirectories ("Documents", perhaps) might be 700, files and directories created in ~ are world-readable by default. Since quite a few programs make the same error that you made of assuming the home directory is private, they don't change the mode on their own files and end up emitting potentially-sensitive world-readable data. Ubuntu sucks.
            – CBHacking
            16 hours ago












            up vote
            1
            down vote













            When you create new files and directories, the initial permissions are controlled by your umask setting. The application creating the item specifies the maximum permissions (typically rwxrwxrwx for directories and executable files, rw-rw-rw- for data files), and then the permissions in umask are subtracted from this.



            So if you want more restrictive permissions, you should set your umask to remove the permissions you don't want to grant. The permissions you show come from having umask 002, so it just disables other=write. If you want to disable other=read/execute as well, you should used:



            umask 007


            Traditionally, the default umask 002 comes from the assumption that all the users on a particular system would be a cooperating community (e.g. programmers in the same department of an organization), so there's little reason to prevent other users from reading your files in general. If you have specific files that are more private, you'd give them more restrictive permissions. If the above assumption is inappropriate for the users of your system, you should use a different default umask in the shell startup scripts.






            share|improve this answer

























              up vote
              1
              down vote













              When you create new files and directories, the initial permissions are controlled by your umask setting. The application creating the item specifies the maximum permissions (typically rwxrwxrwx for directories and executable files, rw-rw-rw- for data files), and then the permissions in umask are subtracted from this.



              So if you want more restrictive permissions, you should set your umask to remove the permissions you don't want to grant. The permissions you show come from having umask 002, so it just disables other=write. If you want to disable other=read/execute as well, you should used:



              umask 007


              Traditionally, the default umask 002 comes from the assumption that all the users on a particular system would be a cooperating community (e.g. programmers in the same department of an organization), so there's little reason to prevent other users from reading your files in general. If you have specific files that are more private, you'd give them more restrictive permissions. If the above assumption is inappropriate for the users of your system, you should use a different default umask in the shell startup scripts.






              share|improve this answer























                up vote
                1
                down vote










                up vote
                1
                down vote









                When you create new files and directories, the initial permissions are controlled by your umask setting. The application creating the item specifies the maximum permissions (typically rwxrwxrwx for directories and executable files, rw-rw-rw- for data files), and then the permissions in umask are subtracted from this.



                So if you want more restrictive permissions, you should set your umask to remove the permissions you don't want to grant. The permissions you show come from having umask 002, so it just disables other=write. If you want to disable other=read/execute as well, you should used:



                umask 007


                Traditionally, the default umask 002 comes from the assumption that all the users on a particular system would be a cooperating community (e.g. programmers in the same department of an organization), so there's little reason to prevent other users from reading your files in general. If you have specific files that are more private, you'd give them more restrictive permissions. If the above assumption is inappropriate for the users of your system, you should use a different default umask in the shell startup scripts.






                share|improve this answer












                When you create new files and directories, the initial permissions are controlled by your umask setting. The application creating the item specifies the maximum permissions (typically rwxrwxrwx for directories and executable files, rw-rw-rw- for data files), and then the permissions in umask are subtracted from this.



                So if you want more restrictive permissions, you should set your umask to remove the permissions you don't want to grant. The permissions you show come from having umask 002, so it just disables other=write. If you want to disable other=read/execute as well, you should used:



                umask 007


                Traditionally, the default umask 002 comes from the assumption that all the users on a particular system would be a cooperating community (e.g. programmers in the same department of an organization), so there's little reason to prevent other users from reading your files in general. If you have specific files that are more private, you'd give them more restrictive permissions. If the above assumption is inappropriate for the users of your system, you should use a different default umask in the shell startup scripts.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered 23 hours ago









                Barmar

                32817




                32817






















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










                     

                    draft saved


                    draft discarded


















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













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












                    wombat trash 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%2fsecurity.stackexchange.com%2fquestions%2f197976%2fwhy-can-others-read-files-by-default-in-ubuntu%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

                    Can a sorcerer learn a 5th-level spell early by creating spell slots using the Font of Magic feature?

                    ts Property 'filter' does not exist on type '{}'

                    Notepad++ export/extract a list of installed plugins