How can I chmod 777 all subfolders of /var/www?












47















I’m running a webserver and FTP server, wherein /var/www is bound to /home/user/www.



I set both directories to chmod 777 (which is fine since it’s for testing only).



I can upload files into /home/user/www, but whenever I create a new directory, I always have to run chmod 777 on that folder.



Otherwise, when I try to browse it, I get the error message




You don't have permission to access /test/ on this server.




Is there a way I could make all sub-folders inside /var/www be accessible by anyone? Or could their permissions be automatically set to 777? It’s annoying that I have to type chmod 777 every time.










share|improve this question




















  • 11





    Just going to leave this here PLEASE CONSIDER NOT USING 777 ON A WEB SERVER. A better question to ask is "How can I get my webserver to work without using 777 permissions?"

    – Marco Ceppi
    Jun 3 '13 at 14:35








  • 11





    sorry that is bad practice and I refuse to answer this :) Hope eveyone agrees :)

    – Rinzwind
    Jun 3 '13 at 14:36











  • See kimbriggs.com/computers/computer-notes/linux-notes/…

    – Panther
    Jun 3 '13 at 17:46
















47















I’m running a webserver and FTP server, wherein /var/www is bound to /home/user/www.



I set both directories to chmod 777 (which is fine since it’s for testing only).



I can upload files into /home/user/www, but whenever I create a new directory, I always have to run chmod 777 on that folder.



Otherwise, when I try to browse it, I get the error message




You don't have permission to access /test/ on this server.




Is there a way I could make all sub-folders inside /var/www be accessible by anyone? Or could their permissions be automatically set to 777? It’s annoying that I have to type chmod 777 every time.










share|improve this question




















  • 11





    Just going to leave this here PLEASE CONSIDER NOT USING 777 ON A WEB SERVER. A better question to ask is "How can I get my webserver to work without using 777 permissions?"

    – Marco Ceppi
    Jun 3 '13 at 14:35








  • 11





    sorry that is bad practice and I refuse to answer this :) Hope eveyone agrees :)

    – Rinzwind
    Jun 3 '13 at 14:36











  • See kimbriggs.com/computers/computer-notes/linux-notes/…

    – Panther
    Jun 3 '13 at 17:46














47












47








47


27






I’m running a webserver and FTP server, wherein /var/www is bound to /home/user/www.



I set both directories to chmod 777 (which is fine since it’s for testing only).



I can upload files into /home/user/www, but whenever I create a new directory, I always have to run chmod 777 on that folder.



Otherwise, when I try to browse it, I get the error message




You don't have permission to access /test/ on this server.




Is there a way I could make all sub-folders inside /var/www be accessible by anyone? Or could their permissions be automatically set to 777? It’s annoying that I have to type chmod 777 every time.










share|improve this question
















I’m running a webserver and FTP server, wherein /var/www is bound to /home/user/www.



I set both directories to chmod 777 (which is fine since it’s for testing only).



I can upload files into /home/user/www, but whenever I create a new directory, I always have to run chmod 777 on that folder.



Otherwise, when I try to browse it, I get the error message




You don't have permission to access /test/ on this server.




Is there a way I could make all sub-folders inside /var/www be accessible by anyone? Or could their permissions be automatically set to 777? It’s annoying that I have to type chmod 777 every time.







permissions apache2 chmod






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jul 17 '15 at 12:48









jokerdino

32.8k21120187




32.8k21120187










asked Jun 3 '13 at 14:32









user1645034user1645034

3742611




3742611








  • 11





    Just going to leave this here PLEASE CONSIDER NOT USING 777 ON A WEB SERVER. A better question to ask is "How can I get my webserver to work without using 777 permissions?"

    – Marco Ceppi
    Jun 3 '13 at 14:35








  • 11





    sorry that is bad practice and I refuse to answer this :) Hope eveyone agrees :)

    – Rinzwind
    Jun 3 '13 at 14:36











  • See kimbriggs.com/computers/computer-notes/linux-notes/…

    – Panther
    Jun 3 '13 at 17:46














  • 11





    Just going to leave this here PLEASE CONSIDER NOT USING 777 ON A WEB SERVER. A better question to ask is "How can I get my webserver to work without using 777 permissions?"

    – Marco Ceppi
    Jun 3 '13 at 14:35








  • 11





    sorry that is bad practice and I refuse to answer this :) Hope eveyone agrees :)

    – Rinzwind
    Jun 3 '13 at 14:36











  • See kimbriggs.com/computers/computer-notes/linux-notes/…

    – Panther
    Jun 3 '13 at 17:46








11




11





Just going to leave this here PLEASE CONSIDER NOT USING 777 ON A WEB SERVER. A better question to ask is "How can I get my webserver to work without using 777 permissions?"

– Marco Ceppi
Jun 3 '13 at 14:35







Just going to leave this here PLEASE CONSIDER NOT USING 777 ON A WEB SERVER. A better question to ask is "How can I get my webserver to work without using 777 permissions?"

– Marco Ceppi
Jun 3 '13 at 14:35






11




11





sorry that is bad practice and I refuse to answer this :) Hope eveyone agrees :)

– Rinzwind
Jun 3 '13 at 14:36





sorry that is bad practice and I refuse to answer this :) Hope eveyone agrees :)

– Rinzwind
Jun 3 '13 at 14:36













See kimbriggs.com/computers/computer-notes/linux-notes/…

– Panther
Jun 3 '13 at 17:46





See kimbriggs.com/computers/computer-notes/linux-notes/…

– Panther
Jun 3 '13 at 17:46










6 Answers
6






active

oldest

votes


















72














This is bad practice, but hopefully you are just using this for development, or you have another good reason. You can specify the permissions when you create a directory using the -m option:



mkdir -m 777 dirname


Or you can set the permissions recursively.



sudo chmod -R 777 /var/www


Before using either of these, really consider if you want your filesystem to be so accessible.





Edit:
As mentioned by Rinzwind here is a better way of accomplishing what you want.



Check what group owns your /var/www directory and add your user to that group.



sudo adduser yourusername group


The group is probably www-data.



Then you will be OK with setting your permissions to 775.






share|improve this answer





















  • 4





    This does what you have asked for but please read this first Why should /var/www not have chmod 777. It is really not recommended practice.

    – Warren Hill
    Jun 3 '13 at 14:56






  • 8





    Please do not help people with a method that is bad practice. I would prefer if you explained how to do it: by adding his user to a group www-data or apache ;)

    – Rinzwind
    Jun 3 '13 at 15:03






  • 4





    Education comes first. Helping people screw up their machine is not the Linux way. So I strongly disagree with you.

    – Rinzwind
    Jun 3 '13 at 15:39






  • 2





    The asker did say this is only for testing. I can definitely understand wanting your development side to be easily accessible so you can work more quickly. I am going to give him the benefit of the doubt, that he is not foolish enough to do this with a production server.

    – Dan
    Jun 3 '13 at 16:18






  • 1





    @dan08 There are better ways to test, including using your home directory. See askubuntu.com/questions/46331/… and kimbriggs.com/computers/computer-notes/linux-notes/… . There are secure ways to accomplish these goals ;)

    – Panther
    Jun 3 '13 at 17:44



















8














Files and directories in Unix may have three types of permissions: read (r), write (w), and execute (x). Each permission may be on or off for each of three categories of users: the file or directory owner; other people in the same group as the owner; and all others.
To change the mode of a file, use the chmod command. The general form is
chmod X@Y file1 file2 ...



chmod a-w file (removes all writing permissions)
chmod o+x file (sets execute permissions for other (public permissions))
chmod u=rx file (Give the owner rx permissions, not w)
chmod go-rwx file (Deny rwx permission for group, others)
chmod g+w file (Give write permission to the group)
chmod a+x file1 file2 (Give execute permission to everybody)
chmod g+rx,o+x file (OK to combine like this with a comma)

u = user that owns the file
g = group that owns the file
o = other (everyone else)
a = all (everybody)

r = read aces to the file
w = write access
x = execute (run) access





share|improve this answer

































    3














    cd /var/www
    find -type d ! -perm 777 -exec chmod 777 {} ;


    for the ftp creating all files with different permissions, you might want to look for the umask of ftpd, how that daemon is started



    Take a look to this site
    https://linuxaria.com/article/linux-shell-understanding-umask-with-examples






    share|improve this answer





















    • 1





      +1 for this is the only answer that updates ONLY folders and not files

      – janmyszkier
      Dec 6 '18 at 9:03



















    3














    Public service announcement:





    Don't ever use chmod 777 to fix problems







    • It's a major security risk if you run any services available to the public, especially web applications (eg PHP).



      The OS's security model assumes that many services (such as your web server) run with reduced privileges, to prevent them being able to modify files. Setting 777 on files breaks this design.



      A remote user could write to or upload files and then trick the server (or some other process on your system) into reading or executing them. Scripts or software may have flaws that allow this. It's very difficult to lock down every single way this could happen if there are world-writable directories.




    • Used in certain system directories (/usr, /etc, /var, and so on), it can break your system in surprising ways.



      Some essential system files need special permissions such as setuid/setgid permissions in order to run. For example, sudo. Avoid changing any file permissions on directories and files set up by the system itself.




    • There's no way to undo it and get back all the old permissions.



      That is, if you had files and folders with various different permissions before, there's no way to go back to those specific permissions - only to change them all to the same thing, which may lose any specific permission settings that were needed on specific files.



    • There is always a more appropriate way of achieving what it is you want to achieve.



    In this case, it looks like you only want your web server to be able to read a directory. Giving world-writable permission is way more than you need to do.



    Track down why the web server can't read that directory (hint: it's probably because your home directory isn't world-readable. World-readable is a lot safer than world-writable - set your home directory to something like 755, or move that www dir outside your home into somewhere like /var/www or /srv).






    share|improve this answer

































      0














      This does not work to me.



      sudo chmod -f 777 /path/to/your/file/or/directory


      I have to use -f also.



      sudo chmod -R -f 777 /path/to/your/file/or/directory





      share|improve this answer































        0














        If you would like to copy permissions and or ownership from another file that you're satisfied with, you can do so using sudo chmod --reference=path/to/file/to/reference path/to/file/you/want/to/change/permissino/to



        And you can do the same thing for file ownership as well.






        share|improve this answer






















          protected by Community Dec 7 '18 at 17:40



          Thank you for your interest in this question.
          Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).



          Would you like to answer one of these unanswered questions instead?














          6 Answers
          6






          active

          oldest

          votes








          6 Answers
          6






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          72














          This is bad practice, but hopefully you are just using this for development, or you have another good reason. You can specify the permissions when you create a directory using the -m option:



          mkdir -m 777 dirname


          Or you can set the permissions recursively.



          sudo chmod -R 777 /var/www


          Before using either of these, really consider if you want your filesystem to be so accessible.





          Edit:
          As mentioned by Rinzwind here is a better way of accomplishing what you want.



          Check what group owns your /var/www directory and add your user to that group.



          sudo adduser yourusername group


          The group is probably www-data.



          Then you will be OK with setting your permissions to 775.






          share|improve this answer





















          • 4





            This does what you have asked for but please read this first Why should /var/www not have chmod 777. It is really not recommended practice.

            – Warren Hill
            Jun 3 '13 at 14:56






          • 8





            Please do not help people with a method that is bad practice. I would prefer if you explained how to do it: by adding his user to a group www-data or apache ;)

            – Rinzwind
            Jun 3 '13 at 15:03






          • 4





            Education comes first. Helping people screw up their machine is not the Linux way. So I strongly disagree with you.

            – Rinzwind
            Jun 3 '13 at 15:39






          • 2





            The asker did say this is only for testing. I can definitely understand wanting your development side to be easily accessible so you can work more quickly. I am going to give him the benefit of the doubt, that he is not foolish enough to do this with a production server.

            – Dan
            Jun 3 '13 at 16:18






          • 1





            @dan08 There are better ways to test, including using your home directory. See askubuntu.com/questions/46331/… and kimbriggs.com/computers/computer-notes/linux-notes/… . There are secure ways to accomplish these goals ;)

            – Panther
            Jun 3 '13 at 17:44
















          72














          This is bad practice, but hopefully you are just using this for development, or you have another good reason. You can specify the permissions when you create a directory using the -m option:



          mkdir -m 777 dirname


          Or you can set the permissions recursively.



          sudo chmod -R 777 /var/www


          Before using either of these, really consider if you want your filesystem to be so accessible.





          Edit:
          As mentioned by Rinzwind here is a better way of accomplishing what you want.



          Check what group owns your /var/www directory and add your user to that group.



          sudo adduser yourusername group


          The group is probably www-data.



          Then you will be OK with setting your permissions to 775.






          share|improve this answer





















          • 4





            This does what you have asked for but please read this first Why should /var/www not have chmod 777. It is really not recommended practice.

            – Warren Hill
            Jun 3 '13 at 14:56






          • 8





            Please do not help people with a method that is bad practice. I would prefer if you explained how to do it: by adding his user to a group www-data or apache ;)

            – Rinzwind
            Jun 3 '13 at 15:03






          • 4





            Education comes first. Helping people screw up their machine is not the Linux way. So I strongly disagree with you.

            – Rinzwind
            Jun 3 '13 at 15:39






          • 2





            The asker did say this is only for testing. I can definitely understand wanting your development side to be easily accessible so you can work more quickly. I am going to give him the benefit of the doubt, that he is not foolish enough to do this with a production server.

            – Dan
            Jun 3 '13 at 16:18






          • 1





            @dan08 There are better ways to test, including using your home directory. See askubuntu.com/questions/46331/… and kimbriggs.com/computers/computer-notes/linux-notes/… . There are secure ways to accomplish these goals ;)

            – Panther
            Jun 3 '13 at 17:44














          72












          72








          72







          This is bad practice, but hopefully you are just using this for development, or you have another good reason. You can specify the permissions when you create a directory using the -m option:



          mkdir -m 777 dirname


          Or you can set the permissions recursively.



          sudo chmod -R 777 /var/www


          Before using either of these, really consider if you want your filesystem to be so accessible.





          Edit:
          As mentioned by Rinzwind here is a better way of accomplishing what you want.



          Check what group owns your /var/www directory and add your user to that group.



          sudo adduser yourusername group


          The group is probably www-data.



          Then you will be OK with setting your permissions to 775.






          share|improve this answer















          This is bad practice, but hopefully you are just using this for development, or you have another good reason. You can specify the permissions when you create a directory using the -m option:



          mkdir -m 777 dirname


          Or you can set the permissions recursively.



          sudo chmod -R 777 /var/www


          Before using either of these, really consider if you want your filesystem to be so accessible.





          Edit:
          As mentioned by Rinzwind here is a better way of accomplishing what you want.



          Check what group owns your /var/www directory and add your user to that group.



          sudo adduser yourusername group


          The group is probably www-data.



          Then you will be OK with setting your permissions to 775.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Jul 17 '15 at 12:51









          jokerdino

          32.8k21120187




          32.8k21120187










          answered Jun 3 '13 at 14:45









          DanDan

          5,22721840




          5,22721840








          • 4





            This does what you have asked for but please read this first Why should /var/www not have chmod 777. It is really not recommended practice.

            – Warren Hill
            Jun 3 '13 at 14:56






          • 8





            Please do not help people with a method that is bad practice. I would prefer if you explained how to do it: by adding his user to a group www-data or apache ;)

            – Rinzwind
            Jun 3 '13 at 15:03






          • 4





            Education comes first. Helping people screw up their machine is not the Linux way. So I strongly disagree with you.

            – Rinzwind
            Jun 3 '13 at 15:39






          • 2





            The asker did say this is only for testing. I can definitely understand wanting your development side to be easily accessible so you can work more quickly. I am going to give him the benefit of the doubt, that he is not foolish enough to do this with a production server.

            – Dan
            Jun 3 '13 at 16:18






          • 1





            @dan08 There are better ways to test, including using your home directory. See askubuntu.com/questions/46331/… and kimbriggs.com/computers/computer-notes/linux-notes/… . There are secure ways to accomplish these goals ;)

            – Panther
            Jun 3 '13 at 17:44














          • 4





            This does what you have asked for but please read this first Why should /var/www not have chmod 777. It is really not recommended practice.

            – Warren Hill
            Jun 3 '13 at 14:56






          • 8





            Please do not help people with a method that is bad practice. I would prefer if you explained how to do it: by adding his user to a group www-data or apache ;)

            – Rinzwind
            Jun 3 '13 at 15:03






          • 4





            Education comes first. Helping people screw up their machine is not the Linux way. So I strongly disagree with you.

            – Rinzwind
            Jun 3 '13 at 15:39






          • 2





            The asker did say this is only for testing. I can definitely understand wanting your development side to be easily accessible so you can work more quickly. I am going to give him the benefit of the doubt, that he is not foolish enough to do this with a production server.

            – Dan
            Jun 3 '13 at 16:18






          • 1





            @dan08 There are better ways to test, including using your home directory. See askubuntu.com/questions/46331/… and kimbriggs.com/computers/computer-notes/linux-notes/… . There are secure ways to accomplish these goals ;)

            – Panther
            Jun 3 '13 at 17:44








          4




          4





          This does what you have asked for but please read this first Why should /var/www not have chmod 777. It is really not recommended practice.

          – Warren Hill
          Jun 3 '13 at 14:56





          This does what you have asked for but please read this first Why should /var/www not have chmod 777. It is really not recommended practice.

          – Warren Hill
          Jun 3 '13 at 14:56




          8




          8





          Please do not help people with a method that is bad practice. I would prefer if you explained how to do it: by adding his user to a group www-data or apache ;)

          – Rinzwind
          Jun 3 '13 at 15:03





          Please do not help people with a method that is bad practice. I would prefer if you explained how to do it: by adding his user to a group www-data or apache ;)

          – Rinzwind
          Jun 3 '13 at 15:03




          4




          4





          Education comes first. Helping people screw up their machine is not the Linux way. So I strongly disagree with you.

          – Rinzwind
          Jun 3 '13 at 15:39





          Education comes first. Helping people screw up their machine is not the Linux way. So I strongly disagree with you.

          – Rinzwind
          Jun 3 '13 at 15:39




          2




          2





          The asker did say this is only for testing. I can definitely understand wanting your development side to be easily accessible so you can work more quickly. I am going to give him the benefit of the doubt, that he is not foolish enough to do this with a production server.

          – Dan
          Jun 3 '13 at 16:18





          The asker did say this is only for testing. I can definitely understand wanting your development side to be easily accessible so you can work more quickly. I am going to give him the benefit of the doubt, that he is not foolish enough to do this with a production server.

          – Dan
          Jun 3 '13 at 16:18




          1




          1





          @dan08 There are better ways to test, including using your home directory. See askubuntu.com/questions/46331/… and kimbriggs.com/computers/computer-notes/linux-notes/… . There are secure ways to accomplish these goals ;)

          – Panther
          Jun 3 '13 at 17:44





          @dan08 There are better ways to test, including using your home directory. See askubuntu.com/questions/46331/… and kimbriggs.com/computers/computer-notes/linux-notes/… . There are secure ways to accomplish these goals ;)

          – Panther
          Jun 3 '13 at 17:44













          8














          Files and directories in Unix may have three types of permissions: read (r), write (w), and execute (x). Each permission may be on or off for each of three categories of users: the file or directory owner; other people in the same group as the owner; and all others.
          To change the mode of a file, use the chmod command. The general form is
          chmod X@Y file1 file2 ...



          chmod a-w file (removes all writing permissions)
          chmod o+x file (sets execute permissions for other (public permissions))
          chmod u=rx file (Give the owner rx permissions, not w)
          chmod go-rwx file (Deny rwx permission for group, others)
          chmod g+w file (Give write permission to the group)
          chmod a+x file1 file2 (Give execute permission to everybody)
          chmod g+rx,o+x file (OK to combine like this with a comma)

          u = user that owns the file
          g = group that owns the file
          o = other (everyone else)
          a = all (everybody)

          r = read aces to the file
          w = write access
          x = execute (run) access





          share|improve this answer






























            8














            Files and directories in Unix may have three types of permissions: read (r), write (w), and execute (x). Each permission may be on or off for each of three categories of users: the file or directory owner; other people in the same group as the owner; and all others.
            To change the mode of a file, use the chmod command. The general form is
            chmod X@Y file1 file2 ...



            chmod a-w file (removes all writing permissions)
            chmod o+x file (sets execute permissions for other (public permissions))
            chmod u=rx file (Give the owner rx permissions, not w)
            chmod go-rwx file (Deny rwx permission for group, others)
            chmod g+w file (Give write permission to the group)
            chmod a+x file1 file2 (Give execute permission to everybody)
            chmod g+rx,o+x file (OK to combine like this with a comma)

            u = user that owns the file
            g = group that owns the file
            o = other (everyone else)
            a = all (everybody)

            r = read aces to the file
            w = write access
            x = execute (run) access





            share|improve this answer




























              8












              8








              8







              Files and directories in Unix may have three types of permissions: read (r), write (w), and execute (x). Each permission may be on or off for each of three categories of users: the file or directory owner; other people in the same group as the owner; and all others.
              To change the mode of a file, use the chmod command. The general form is
              chmod X@Y file1 file2 ...



              chmod a-w file (removes all writing permissions)
              chmod o+x file (sets execute permissions for other (public permissions))
              chmod u=rx file (Give the owner rx permissions, not w)
              chmod go-rwx file (Deny rwx permission for group, others)
              chmod g+w file (Give write permission to the group)
              chmod a+x file1 file2 (Give execute permission to everybody)
              chmod g+rx,o+x file (OK to combine like this with a comma)

              u = user that owns the file
              g = group that owns the file
              o = other (everyone else)
              a = all (everybody)

              r = read aces to the file
              w = write access
              x = execute (run) access





              share|improve this answer















              Files and directories in Unix may have three types of permissions: read (r), write (w), and execute (x). Each permission may be on or off for each of three categories of users: the file or directory owner; other people in the same group as the owner; and all others.
              To change the mode of a file, use the chmod command. The general form is
              chmod X@Y file1 file2 ...



              chmod a-w file (removes all writing permissions)
              chmod o+x file (sets execute permissions for other (public permissions))
              chmod u=rx file (Give the owner rx permissions, not w)
              chmod go-rwx file (Deny rwx permission for group, others)
              chmod g+w file (Give write permission to the group)
              chmod a+x file1 file2 (Give execute permission to everybody)
              chmod g+rx,o+x file (OK to combine like this with a comma)

              u = user that owns the file
              g = group that owns the file
              o = other (everyone else)
              a = all (everybody)

              r = read aces to the file
              w = write access
              x = execute (run) access






              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited Aug 9 '16 at 12:31









              anonymous2

              3,36741849




              3,36741849










              answered Aug 9 '16 at 6:19









              Lokesh Kumar BandiLokesh Kumar Bandi

              8111




              8111























                  3














                  cd /var/www
                  find -type d ! -perm 777 -exec chmod 777 {} ;


                  for the ftp creating all files with different permissions, you might want to look for the umask of ftpd, how that daemon is started



                  Take a look to this site
                  https://linuxaria.com/article/linux-shell-understanding-umask-with-examples






                  share|improve this answer





















                  • 1





                    +1 for this is the only answer that updates ONLY folders and not files

                    – janmyszkier
                    Dec 6 '18 at 9:03
















                  3














                  cd /var/www
                  find -type d ! -perm 777 -exec chmod 777 {} ;


                  for the ftp creating all files with different permissions, you might want to look for the umask of ftpd, how that daemon is started



                  Take a look to this site
                  https://linuxaria.com/article/linux-shell-understanding-umask-with-examples






                  share|improve this answer





















                  • 1





                    +1 for this is the only answer that updates ONLY folders and not files

                    – janmyszkier
                    Dec 6 '18 at 9:03














                  3












                  3








                  3







                  cd /var/www
                  find -type d ! -perm 777 -exec chmod 777 {} ;


                  for the ftp creating all files with different permissions, you might want to look for the umask of ftpd, how that daemon is started



                  Take a look to this site
                  https://linuxaria.com/article/linux-shell-understanding-umask-with-examples






                  share|improve this answer















                  cd /var/www
                  find -type d ! -perm 777 -exec chmod 777 {} ;


                  for the ftp creating all files with different permissions, you might want to look for the umask of ftpd, how that daemon is started



                  Take a look to this site
                  https://linuxaria.com/article/linux-shell-understanding-umask-with-examples







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Nov 2 '17 at 23:53

























                  answered Nov 2 '17 at 23:46









                  Jose PlaJose Pla

                  312




                  312








                  • 1





                    +1 for this is the only answer that updates ONLY folders and not files

                    – janmyszkier
                    Dec 6 '18 at 9:03














                  • 1





                    +1 for this is the only answer that updates ONLY folders and not files

                    – janmyszkier
                    Dec 6 '18 at 9:03








                  1




                  1





                  +1 for this is the only answer that updates ONLY folders and not files

                  – janmyszkier
                  Dec 6 '18 at 9:03





                  +1 for this is the only answer that updates ONLY folders and not files

                  – janmyszkier
                  Dec 6 '18 at 9:03











                  3














                  Public service announcement:





                  Don't ever use chmod 777 to fix problems







                  • It's a major security risk if you run any services available to the public, especially web applications (eg PHP).



                    The OS's security model assumes that many services (such as your web server) run with reduced privileges, to prevent them being able to modify files. Setting 777 on files breaks this design.



                    A remote user could write to or upload files and then trick the server (or some other process on your system) into reading or executing them. Scripts or software may have flaws that allow this. It's very difficult to lock down every single way this could happen if there are world-writable directories.




                  • Used in certain system directories (/usr, /etc, /var, and so on), it can break your system in surprising ways.



                    Some essential system files need special permissions such as setuid/setgid permissions in order to run. For example, sudo. Avoid changing any file permissions on directories and files set up by the system itself.




                  • There's no way to undo it and get back all the old permissions.



                    That is, if you had files and folders with various different permissions before, there's no way to go back to those specific permissions - only to change them all to the same thing, which may lose any specific permission settings that were needed on specific files.



                  • There is always a more appropriate way of achieving what it is you want to achieve.



                  In this case, it looks like you only want your web server to be able to read a directory. Giving world-writable permission is way more than you need to do.



                  Track down why the web server can't read that directory (hint: it's probably because your home directory isn't world-readable. World-readable is a lot safer than world-writable - set your home directory to something like 755, or move that www dir outside your home into somewhere like /var/www or /srv).






                  share|improve this answer






























                    3














                    Public service announcement:





                    Don't ever use chmod 777 to fix problems







                    • It's a major security risk if you run any services available to the public, especially web applications (eg PHP).



                      The OS's security model assumes that many services (such as your web server) run with reduced privileges, to prevent them being able to modify files. Setting 777 on files breaks this design.



                      A remote user could write to or upload files and then trick the server (or some other process on your system) into reading or executing them. Scripts or software may have flaws that allow this. It's very difficult to lock down every single way this could happen if there are world-writable directories.




                    • Used in certain system directories (/usr, /etc, /var, and so on), it can break your system in surprising ways.



                      Some essential system files need special permissions such as setuid/setgid permissions in order to run. For example, sudo. Avoid changing any file permissions on directories and files set up by the system itself.




                    • There's no way to undo it and get back all the old permissions.



                      That is, if you had files and folders with various different permissions before, there's no way to go back to those specific permissions - only to change them all to the same thing, which may lose any specific permission settings that were needed on specific files.



                    • There is always a more appropriate way of achieving what it is you want to achieve.



                    In this case, it looks like you only want your web server to be able to read a directory. Giving world-writable permission is way more than you need to do.



                    Track down why the web server can't read that directory (hint: it's probably because your home directory isn't world-readable. World-readable is a lot safer than world-writable - set your home directory to something like 755, or move that www dir outside your home into somewhere like /var/www or /srv).






                    share|improve this answer




























                      3












                      3








                      3







                      Public service announcement:





                      Don't ever use chmod 777 to fix problems







                      • It's a major security risk if you run any services available to the public, especially web applications (eg PHP).



                        The OS's security model assumes that many services (such as your web server) run with reduced privileges, to prevent them being able to modify files. Setting 777 on files breaks this design.



                        A remote user could write to or upload files and then trick the server (or some other process on your system) into reading or executing them. Scripts or software may have flaws that allow this. It's very difficult to lock down every single way this could happen if there are world-writable directories.




                      • Used in certain system directories (/usr, /etc, /var, and so on), it can break your system in surprising ways.



                        Some essential system files need special permissions such as setuid/setgid permissions in order to run. For example, sudo. Avoid changing any file permissions on directories and files set up by the system itself.




                      • There's no way to undo it and get back all the old permissions.



                        That is, if you had files and folders with various different permissions before, there's no way to go back to those specific permissions - only to change them all to the same thing, which may lose any specific permission settings that were needed on specific files.



                      • There is always a more appropriate way of achieving what it is you want to achieve.



                      In this case, it looks like you only want your web server to be able to read a directory. Giving world-writable permission is way more than you need to do.



                      Track down why the web server can't read that directory (hint: it's probably because your home directory isn't world-readable. World-readable is a lot safer than world-writable - set your home directory to something like 755, or move that www dir outside your home into somewhere like /var/www or /srv).






                      share|improve this answer















                      Public service announcement:





                      Don't ever use chmod 777 to fix problems







                      • It's a major security risk if you run any services available to the public, especially web applications (eg PHP).



                        The OS's security model assumes that many services (such as your web server) run with reduced privileges, to prevent them being able to modify files. Setting 777 on files breaks this design.



                        A remote user could write to or upload files and then trick the server (or some other process on your system) into reading or executing them. Scripts or software may have flaws that allow this. It's very difficult to lock down every single way this could happen if there are world-writable directories.




                      • Used in certain system directories (/usr, /etc, /var, and so on), it can break your system in surprising ways.



                        Some essential system files need special permissions such as setuid/setgid permissions in order to run. For example, sudo. Avoid changing any file permissions on directories and files set up by the system itself.




                      • There's no way to undo it and get back all the old permissions.



                        That is, if you had files and folders with various different permissions before, there's no way to go back to those specific permissions - only to change them all to the same thing, which may lose any specific permission settings that were needed on specific files.



                      • There is always a more appropriate way of achieving what it is you want to achieve.



                      In this case, it looks like you only want your web server to be able to read a directory. Giving world-writable permission is way more than you need to do.



                      Track down why the web server can't read that directory (hint: it's probably because your home directory isn't world-readable. World-readable is a lot safer than world-writable - set your home directory to something like 755, or move that www dir outside your home into somewhere like /var/www or /srv).







                      share|improve this answer














                      share|improve this answer



                      share|improve this answer








                      edited Nov 3 '17 at 0:26

























                      answered Nov 3 '17 at 0:09









                      thomasrutterthomasrutter

                      27.1k46689




                      27.1k46689























                          0














                          This does not work to me.



                          sudo chmod -f 777 /path/to/your/file/or/directory


                          I have to use -f also.



                          sudo chmod -R -f 777 /path/to/your/file/or/directory





                          share|improve this answer




























                            0














                            This does not work to me.



                            sudo chmod -f 777 /path/to/your/file/or/directory


                            I have to use -f also.



                            sudo chmod -R -f 777 /path/to/your/file/or/directory





                            share|improve this answer


























                              0












                              0








                              0







                              This does not work to me.



                              sudo chmod -f 777 /path/to/your/file/or/directory


                              I have to use -f also.



                              sudo chmod -R -f 777 /path/to/your/file/or/directory





                              share|improve this answer













                              This does not work to me.



                              sudo chmod -f 777 /path/to/your/file/or/directory


                              I have to use -f also.



                              sudo chmod -R -f 777 /path/to/your/file/or/directory






                              share|improve this answer












                              share|improve this answer



                              share|improve this answer










                              answered Dec 21 '17 at 12:10









                              Janaka PushpakumaraJanaka Pushpakumara

                              10612




                              10612























                                  0














                                  If you would like to copy permissions and or ownership from another file that you're satisfied with, you can do so using sudo chmod --reference=path/to/file/to/reference path/to/file/you/want/to/change/permissino/to



                                  And you can do the same thing for file ownership as well.






                                  share|improve this answer




























                                    0














                                    If you would like to copy permissions and or ownership from another file that you're satisfied with, you can do so using sudo chmod --reference=path/to/file/to/reference path/to/file/you/want/to/change/permissino/to



                                    And you can do the same thing for file ownership as well.






                                    share|improve this answer


























                                      0












                                      0








                                      0







                                      If you would like to copy permissions and or ownership from another file that you're satisfied with, you can do so using sudo chmod --reference=path/to/file/to/reference path/to/file/you/want/to/change/permissino/to



                                      And you can do the same thing for file ownership as well.






                                      share|improve this answer













                                      If you would like to copy permissions and or ownership from another file that you're satisfied with, you can do so using sudo chmod --reference=path/to/file/to/reference path/to/file/you/want/to/change/permissino/to



                                      And you can do the same thing for file ownership as well.







                                      share|improve this answer












                                      share|improve this answer



                                      share|improve this answer










                                      answered Jul 2 '18 at 19:01









                                      Amir KhalilAmir Khalil

                                      11




                                      11

















                                          protected by Community Dec 7 '18 at 17:40



                                          Thank you for your interest in this question.
                                          Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).



                                          Would you like to answer one of these unanswered questions instead?



                                          Popular posts from this blog

                                          How did Captain America manage to do this?

                                          迪纳利

                                          南乌拉尔铁路局