How to Chown a directory recursively including hidden files or directoriesBash snippet to move all files in a...

How does 取材で訪れた integrate into this sentence?

Calculate the frequency of characters in a string

Print a physical multiplication table

Bash - pair each line of file

What can I do if I am asked to learn different programming languages very frequently?

gerund and noun applications

Why are there no stars visible in cislunar space?

World War I as a war of liberals against authoritarians?

Do native speakers use "ultima" and "proxima" frequently in spoken English?

Hausdorff dimension of the boundary of fibres of Lipschitz maps

Print last inputted byte

Wrapping homogeneous Python objects

What does "Four-F." mean?

Comment Box for Substitution Method of Integrals

Help prove this basic trig identity please!

Is honey really a supersaturated solution? Does heating to un-crystalize redissolve it or melt it?

Recruiter wants very extensive technical details about all of my previous work

Help rendering a complicated sum/product formula

Loading the leaflet Map in Lightning Web Component

Generic TVP tradeoffs?

How to terminate ping <dest> &

Is it insecure to send a password in a `curl` command?

What (if any) is the reason to buy in small local stores?

Unfrosted light bulb



How to Chown a directory recursively including hidden files or directories


Bash snippet to move all files in a directory into that directoryCan't modify or chown files on readynas nfs shareHow can I recursively verify the permissions within a given subdirectory?exclude all hidden files and directories in solarisOnly allow a user to CHMOD and CHOWN in their home directory or a specified directoryCannot login to Solaris due to chown on /usr directoryCannot login to Solaris due to chown on /usr directoryChange group owner of file, but not the ownerLimit sudo to only one directory and it's subdirectories by sudoers fileUsing chown: Any substantial difference between assigning ownership of the entire directory vs just the files in it?













33















Seems like chown with the recursive flag will not work on hidden directories or files. Is there any simple workaround for that?










share|improve this question



























    33















    Seems like chown with the recursive flag will not work on hidden directories or files. Is there any simple workaround for that?










    share|improve this question

























      33












      33








      33


      7






      Seems like chown with the recursive flag will not work on hidden directories or files. Is there any simple workaround for that?










      share|improve this question














      Seems like chown with the recursive flag will not work on hidden directories or files. Is there any simple workaround for that?







      unix chown






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jun 30 '10 at 20:23









      tobytoby

      266136




      266136






















          8 Answers
          8






          active

          oldest

          votes


















          53














          I'm pretty sure the -R flag does work - it always has for me anyway. What won't work, and what tripped me up early in my command line usage, is using * in a directory with hidden files/directories. So doing



          $ chown -R /home/user/*


          will not do the hidden files and directories. However if you follow it with



          $ chown -R /home/user/.[^.]*


          then you will do all the hidden files, (but not . or .. as /home/user/.* would do). Having said all that, I would expect



          $ chown -R /home/user


          to get all the hidden files and directories inside /home/user - though that will of course also change the permissions of the directory itself, which might not be what you intended.






          share|improve this answer





















          • 2





            Doing a chown on the directory has the side effect that you change the permissions on the directory itself as well as all of its contents, which may or may not be what you want.

            – wfaulk
            May 10 '12 at 22:44











          • A+ worked like a charm for me.

            – SuperFamousGuy
            Feb 5 '15 at 0:11











          • I tried chown nginx:nginx -R /path/to/.[^.]* and it only changed ownership to .dot hidden files. not all.

            – Pathros
            Jun 23 '18 at 17:35



















          8














          "chown -R" works, but an alternative would be using find.



           find /path/to/dir -exec chown USER {} ;





          share|improve this answer



















          • 5





            note that with GNU find, using + instead of ; as the terminator to the -exec will be more efficient as it will use the minimum needed number of forks to chown instead of one fork per file/directory

            – stew
            May 14 '12 at 2:31



















          8














          i believe the following command should work for this



          chown -hR userid:usergroup /nameofdirectory/nameofsubdir/





          share|improve this answer





















          • 1





            -h affect symbolic links instead of any referenced file (useful only on systems that can change the ownership of a symlink)

            – R. van Twisk
            Feb 24 '17 at 10:29



















          2














          You can change the dotglob attribute temporarily to expand . files and then revert it.



          shopt -s dotglob; chown -R user:group FOLDER; shopt -u dotglob


          More on dotglob can be found here






          share|improve this answer































            1














            Also, if you're like me you'll probably be running chown mostly from the current directory. I was accustomed to running it like this: chown rails.rails -R * . Simply changing the asterisk to a dot (short for the current directory) like this: chown rails.rails -R . brings in all hidden directories.






            share|improve this answer



















            • 2





              With the side effect that you change the permissions on the current directory as well as all of its contents, which may or may not be what you want.

              – wfaulk
              May 10 '12 at 22:39



















            1














            Using for-loop with ls -A option, We can find all hidden files and directory exclude . and .. and then change the ownership for all hidden files and directory.



            for i in `ls -A | grep "^."`;do chown -R user:group $i;done


            Use xargs option with ls -A



            ls -A | grep "^." | xargs chown user:group


            For More details Click Here and Visit my Site






            share|improve this answer

































              0














              To chown ALL files in current directory and subdirectories for current user;



              find . -exec chown $(whoami) {} ;


              or if user can't chown some files due to restricted permissions;



              sudo find . -exec chown $(logname) {} ;




              share








              New contributor




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




























                -2














                You could do something like



                for i in `ls -A`;do chown -R user:group $i;done


                The -A (capital A) is important as it excludes '.' and '..'






                share|improve this answer


























                • This will change only files and subdirectories in the current directory, not any lower levels. (Which may be what the OP wants.) It will also break on filenames and directory names with spaces (or tabs) in them.

                  – wfaulk
                  May 10 '12 at 22:48











                Your Answer








                StackExchange.ready(function() {
                var channelOptions = {
                tags: "".split(" "),
                id: "2"
                };
                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',
                autoActivateHeartbeat: false,
                convertImagesToLinks: true,
                noModals: true,
                showLowRepImageUploadWarning: true,
                reputationToPostImages: 10,
                bindNavPrevention: true,
                postfix: "",
                imageUploader: {
                brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                allowUrls: true
                },
                onDemand: true,
                discardSelector: ".discard-answer"
                ,immediatelyShowMarkdownHelp:true
                });


                }
                });














                draft saved

                draft discarded


















                StackExchange.ready(
                function () {
                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f156437%2fhow-to-chown-a-directory-recursively-including-hidden-files-or-directories%23new-answer', 'question_page');
                }
                );

                Post as a guest















                Required, but never shown

























                8 Answers
                8






                active

                oldest

                votes








                8 Answers
                8






                active

                oldest

                votes









                active

                oldest

                votes






                active

                oldest

                votes









                53














                I'm pretty sure the -R flag does work - it always has for me anyway. What won't work, and what tripped me up early in my command line usage, is using * in a directory with hidden files/directories. So doing



                $ chown -R /home/user/*


                will not do the hidden files and directories. However if you follow it with



                $ chown -R /home/user/.[^.]*


                then you will do all the hidden files, (but not . or .. as /home/user/.* would do). Having said all that, I would expect



                $ chown -R /home/user


                to get all the hidden files and directories inside /home/user - though that will of course also change the permissions of the directory itself, which might not be what you intended.






                share|improve this answer





















                • 2





                  Doing a chown on the directory has the side effect that you change the permissions on the directory itself as well as all of its contents, which may or may not be what you want.

                  – wfaulk
                  May 10 '12 at 22:44











                • A+ worked like a charm for me.

                  – SuperFamousGuy
                  Feb 5 '15 at 0:11











                • I tried chown nginx:nginx -R /path/to/.[^.]* and it only changed ownership to .dot hidden files. not all.

                  – Pathros
                  Jun 23 '18 at 17:35
















                53














                I'm pretty sure the -R flag does work - it always has for me anyway. What won't work, and what tripped me up early in my command line usage, is using * in a directory with hidden files/directories. So doing



                $ chown -R /home/user/*


                will not do the hidden files and directories. However if you follow it with



                $ chown -R /home/user/.[^.]*


                then you will do all the hidden files, (but not . or .. as /home/user/.* would do). Having said all that, I would expect



                $ chown -R /home/user


                to get all the hidden files and directories inside /home/user - though that will of course also change the permissions of the directory itself, which might not be what you intended.






                share|improve this answer





















                • 2





                  Doing a chown on the directory has the side effect that you change the permissions on the directory itself as well as all of its contents, which may or may not be what you want.

                  – wfaulk
                  May 10 '12 at 22:44











                • A+ worked like a charm for me.

                  – SuperFamousGuy
                  Feb 5 '15 at 0:11











                • I tried chown nginx:nginx -R /path/to/.[^.]* and it only changed ownership to .dot hidden files. not all.

                  – Pathros
                  Jun 23 '18 at 17:35














                53












                53








                53







                I'm pretty sure the -R flag does work - it always has for me anyway. What won't work, and what tripped me up early in my command line usage, is using * in a directory with hidden files/directories. So doing



                $ chown -R /home/user/*


                will not do the hidden files and directories. However if you follow it with



                $ chown -R /home/user/.[^.]*


                then you will do all the hidden files, (but not . or .. as /home/user/.* would do). Having said all that, I would expect



                $ chown -R /home/user


                to get all the hidden files and directories inside /home/user - though that will of course also change the permissions of the directory itself, which might not be what you intended.






                share|improve this answer















                I'm pretty sure the -R flag does work - it always has for me anyway. What won't work, and what tripped me up early in my command line usage, is using * in a directory with hidden files/directories. So doing



                $ chown -R /home/user/*


                will not do the hidden files and directories. However if you follow it with



                $ chown -R /home/user/.[^.]*


                then you will do all the hidden files, (but not . or .. as /home/user/.* would do). Having said all that, I would expect



                $ chown -R /home/user


                to get all the hidden files and directories inside /home/user - though that will of course also change the permissions of the directory itself, which might not be what you intended.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited May 29 '12 at 10:14

























                answered Jun 30 '10 at 22:46









                Hamish DownerHamish Downer

                6,53752947




                6,53752947








                • 2





                  Doing a chown on the directory has the side effect that you change the permissions on the directory itself as well as all of its contents, which may or may not be what you want.

                  – wfaulk
                  May 10 '12 at 22:44











                • A+ worked like a charm for me.

                  – SuperFamousGuy
                  Feb 5 '15 at 0:11











                • I tried chown nginx:nginx -R /path/to/.[^.]* and it only changed ownership to .dot hidden files. not all.

                  – Pathros
                  Jun 23 '18 at 17:35














                • 2





                  Doing a chown on the directory has the side effect that you change the permissions on the directory itself as well as all of its contents, which may or may not be what you want.

                  – wfaulk
                  May 10 '12 at 22:44











                • A+ worked like a charm for me.

                  – SuperFamousGuy
                  Feb 5 '15 at 0:11











                • I tried chown nginx:nginx -R /path/to/.[^.]* and it only changed ownership to .dot hidden files. not all.

                  – Pathros
                  Jun 23 '18 at 17:35








                2




                2





                Doing a chown on the directory has the side effect that you change the permissions on the directory itself as well as all of its contents, which may or may not be what you want.

                – wfaulk
                May 10 '12 at 22:44





                Doing a chown on the directory has the side effect that you change the permissions on the directory itself as well as all of its contents, which may or may not be what you want.

                – wfaulk
                May 10 '12 at 22:44













                A+ worked like a charm for me.

                – SuperFamousGuy
                Feb 5 '15 at 0:11





                A+ worked like a charm for me.

                – SuperFamousGuy
                Feb 5 '15 at 0:11













                I tried chown nginx:nginx -R /path/to/.[^.]* and it only changed ownership to .dot hidden files. not all.

                – Pathros
                Jun 23 '18 at 17:35





                I tried chown nginx:nginx -R /path/to/.[^.]* and it only changed ownership to .dot hidden files. not all.

                – Pathros
                Jun 23 '18 at 17:35













                8














                "chown -R" works, but an alternative would be using find.



                 find /path/to/dir -exec chown USER {} ;





                share|improve this answer



















                • 5





                  note that with GNU find, using + instead of ; as the terminator to the -exec will be more efficient as it will use the minimum needed number of forks to chown instead of one fork per file/directory

                  – stew
                  May 14 '12 at 2:31
















                8














                "chown -R" works, but an alternative would be using find.



                 find /path/to/dir -exec chown USER {} ;





                share|improve this answer



















                • 5





                  note that with GNU find, using + instead of ; as the terminator to the -exec will be more efficient as it will use the minimum needed number of forks to chown instead of one fork per file/directory

                  – stew
                  May 14 '12 at 2:31














                8












                8








                8







                "chown -R" works, but an alternative would be using find.



                 find /path/to/dir -exec chown USER {} ;





                share|improve this answer













                "chown -R" works, but an alternative would be using find.



                 find /path/to/dir -exec chown USER {} ;






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Jun 30 '10 at 20:34









                hayalcihayalci

                3,21511831




                3,21511831








                • 5





                  note that with GNU find, using + instead of ; as the terminator to the -exec will be more efficient as it will use the minimum needed number of forks to chown instead of one fork per file/directory

                  – stew
                  May 14 '12 at 2:31














                • 5





                  note that with GNU find, using + instead of ; as the terminator to the -exec will be more efficient as it will use the minimum needed number of forks to chown instead of one fork per file/directory

                  – stew
                  May 14 '12 at 2:31








                5




                5





                note that with GNU find, using + instead of ; as the terminator to the -exec will be more efficient as it will use the minimum needed number of forks to chown instead of one fork per file/directory

                – stew
                May 14 '12 at 2:31





                note that with GNU find, using + instead of ; as the terminator to the -exec will be more efficient as it will use the minimum needed number of forks to chown instead of one fork per file/directory

                – stew
                May 14 '12 at 2:31











                8














                i believe the following command should work for this



                chown -hR userid:usergroup /nameofdirectory/nameofsubdir/





                share|improve this answer





















                • 1





                  -h affect symbolic links instead of any referenced file (useful only on systems that can change the ownership of a symlink)

                  – R. van Twisk
                  Feb 24 '17 at 10:29
















                8














                i believe the following command should work for this



                chown -hR userid:usergroup /nameofdirectory/nameofsubdir/





                share|improve this answer





















                • 1





                  -h affect symbolic links instead of any referenced file (useful only on systems that can change the ownership of a symlink)

                  – R. van Twisk
                  Feb 24 '17 at 10:29














                8












                8








                8







                i believe the following command should work for this



                chown -hR userid:usergroup /nameofdirectory/nameofsubdir/





                share|improve this answer















                i believe the following command should work for this



                chown -hR userid:usergroup /nameofdirectory/nameofsubdir/






                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited May 14 '12 at 2:13









                hayalci

                3,21511831




                3,21511831










                answered Jun 30 '10 at 22:51









                MattrixHaxMattrixHax

                10112




                10112








                • 1





                  -h affect symbolic links instead of any referenced file (useful only on systems that can change the ownership of a symlink)

                  – R. van Twisk
                  Feb 24 '17 at 10:29














                • 1





                  -h affect symbolic links instead of any referenced file (useful only on systems that can change the ownership of a symlink)

                  – R. van Twisk
                  Feb 24 '17 at 10:29








                1




                1





                -h affect symbolic links instead of any referenced file (useful only on systems that can change the ownership of a symlink)

                – R. van Twisk
                Feb 24 '17 at 10:29





                -h affect symbolic links instead of any referenced file (useful only on systems that can change the ownership of a symlink)

                – R. van Twisk
                Feb 24 '17 at 10:29











                2














                You can change the dotglob attribute temporarily to expand . files and then revert it.



                shopt -s dotglob; chown -R user:group FOLDER; shopt -u dotglob


                More on dotglob can be found here






                share|improve this answer




























                  2














                  You can change the dotglob attribute temporarily to expand . files and then revert it.



                  shopt -s dotglob; chown -R user:group FOLDER; shopt -u dotglob


                  More on dotglob can be found here






                  share|improve this answer


























                    2












                    2








                    2







                    You can change the dotglob attribute temporarily to expand . files and then revert it.



                    shopt -s dotglob; chown -R user:group FOLDER; shopt -u dotglob


                    More on dotglob can be found here






                    share|improve this answer













                    You can change the dotglob attribute temporarily to expand . files and then revert it.



                    shopt -s dotglob; chown -R user:group FOLDER; shopt -u dotglob


                    More on dotglob can be found here







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Aug 17 '16 at 6:44









                    stdcallstdcall

                    1427




                    1427























                        1














                        Also, if you're like me you'll probably be running chown mostly from the current directory. I was accustomed to running it like this: chown rails.rails -R * . Simply changing the asterisk to a dot (short for the current directory) like this: chown rails.rails -R . brings in all hidden directories.






                        share|improve this answer



















                        • 2





                          With the side effect that you change the permissions on the current directory as well as all of its contents, which may or may not be what you want.

                          – wfaulk
                          May 10 '12 at 22:39
















                        1














                        Also, if you're like me you'll probably be running chown mostly from the current directory. I was accustomed to running it like this: chown rails.rails -R * . Simply changing the asterisk to a dot (short for the current directory) like this: chown rails.rails -R . brings in all hidden directories.






                        share|improve this answer



















                        • 2





                          With the side effect that you change the permissions on the current directory as well as all of its contents, which may or may not be what you want.

                          – wfaulk
                          May 10 '12 at 22:39














                        1












                        1








                        1







                        Also, if you're like me you'll probably be running chown mostly from the current directory. I was accustomed to running it like this: chown rails.rails -R * . Simply changing the asterisk to a dot (short for the current directory) like this: chown rails.rails -R . brings in all hidden directories.






                        share|improve this answer













                        Also, if you're like me you'll probably be running chown mostly from the current directory. I was accustomed to running it like this: chown rails.rails -R * . Simply changing the asterisk to a dot (short for the current directory) like this: chown rails.rails -R . brings in all hidden directories.







                        share|improve this answer












                        share|improve this answer



                        share|improve this answer










                        answered May 10 '12 at 21:49









                        CraigCraig

                        13917




                        13917








                        • 2





                          With the side effect that you change the permissions on the current directory as well as all of its contents, which may or may not be what you want.

                          – wfaulk
                          May 10 '12 at 22:39














                        • 2





                          With the side effect that you change the permissions on the current directory as well as all of its contents, which may or may not be what you want.

                          – wfaulk
                          May 10 '12 at 22:39








                        2




                        2





                        With the side effect that you change the permissions on the current directory as well as all of its contents, which may or may not be what you want.

                        – wfaulk
                        May 10 '12 at 22:39





                        With the side effect that you change the permissions on the current directory as well as all of its contents, which may or may not be what you want.

                        – wfaulk
                        May 10 '12 at 22:39











                        1














                        Using for-loop with ls -A option, We can find all hidden files and directory exclude . and .. and then change the ownership for all hidden files and directory.



                        for i in `ls -A | grep "^."`;do chown -R user:group $i;done


                        Use xargs option with ls -A



                        ls -A | grep "^." | xargs chown user:group


                        For More details Click Here and Visit my Site






                        share|improve this answer






























                          1














                          Using for-loop with ls -A option, We can find all hidden files and directory exclude . and .. and then change the ownership for all hidden files and directory.



                          for i in `ls -A | grep "^."`;do chown -R user:group $i;done


                          Use xargs option with ls -A



                          ls -A | grep "^." | xargs chown user:group


                          For More details Click Here and Visit my Site






                          share|improve this answer




























                            1












                            1








                            1







                            Using for-loop with ls -A option, We can find all hidden files and directory exclude . and .. and then change the ownership for all hidden files and directory.



                            for i in `ls -A | grep "^."`;do chown -R user:group $i;done


                            Use xargs option with ls -A



                            ls -A | grep "^." | xargs chown user:group


                            For More details Click Here and Visit my Site






                            share|improve this answer















                            Using for-loop with ls -A option, We can find all hidden files and directory exclude . and .. and then change the ownership for all hidden files and directory.



                            for i in `ls -A | grep "^."`;do chown -R user:group $i;done


                            Use xargs option with ls -A



                            ls -A | grep "^." | xargs chown user:group


                            For More details Click Here and Visit my Site







                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited Jul 8 '18 at 13:07

























                            answered Jul 8 '18 at 12:48









                            Ranjeet_Automation_TesterRanjeet_Automation_Tester

                            112




                            112























                                0














                                To chown ALL files in current directory and subdirectories for current user;



                                find . -exec chown $(whoami) {} ;


                                or if user can't chown some files due to restricted permissions;



                                sudo find . -exec chown $(logname) {} ;




                                share








                                New contributor




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

























                                  0














                                  To chown ALL files in current directory and subdirectories for current user;



                                  find . -exec chown $(whoami) {} ;


                                  or if user can't chown some files due to restricted permissions;



                                  sudo find . -exec chown $(logname) {} ;




                                  share








                                  New contributor




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























                                    0












                                    0








                                    0







                                    To chown ALL files in current directory and subdirectories for current user;



                                    find . -exec chown $(whoami) {} ;


                                    or if user can't chown some files due to restricted permissions;



                                    sudo find . -exec chown $(logname) {} ;




                                    share








                                    New contributor




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










                                    To chown ALL files in current directory and subdirectories for current user;



                                    find . -exec chown $(whoami) {} ;


                                    or if user can't chown some files due to restricted permissions;



                                    sudo find . -exec chown $(logname) {} ;





                                    share








                                    New contributor




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








                                    share


                                    share






                                    New contributor




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









                                    answered 2 mins ago









                                    5p0ng3b0b5p0ng3b0b

                                    1




                                    1




                                    New contributor




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





                                    New contributor





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






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























                                        -2














                                        You could do something like



                                        for i in `ls -A`;do chown -R user:group $i;done


                                        The -A (capital A) is important as it excludes '.' and '..'






                                        share|improve this answer


























                                        • This will change only files and subdirectories in the current directory, not any lower levels. (Which may be what the OP wants.) It will also break on filenames and directory names with spaces (or tabs) in them.

                                          – wfaulk
                                          May 10 '12 at 22:48
















                                        -2














                                        You could do something like



                                        for i in `ls -A`;do chown -R user:group $i;done


                                        The -A (capital A) is important as it excludes '.' and '..'






                                        share|improve this answer


























                                        • This will change only files and subdirectories in the current directory, not any lower levels. (Which may be what the OP wants.) It will also break on filenames and directory names with spaces (or tabs) in them.

                                          – wfaulk
                                          May 10 '12 at 22:48














                                        -2












                                        -2








                                        -2







                                        You could do something like



                                        for i in `ls -A`;do chown -R user:group $i;done


                                        The -A (capital A) is important as it excludes '.' and '..'






                                        share|improve this answer















                                        You could do something like



                                        for i in `ls -A`;do chown -R user:group $i;done


                                        The -A (capital A) is important as it excludes '.' and '..'







                                        share|improve this answer














                                        share|improve this answer



                                        share|improve this answer








                                        edited May 10 '12 at 22:46









                                        wfaulk

                                        5,31363767




                                        5,31363767










                                        answered Jun 30 '10 at 20:33









                                        ZypherZypher

                                        34.3k44492




                                        34.3k44492













                                        • This will change only files and subdirectories in the current directory, not any lower levels. (Which may be what the OP wants.) It will also break on filenames and directory names with spaces (or tabs) in them.

                                          – wfaulk
                                          May 10 '12 at 22:48



















                                        • This will change only files and subdirectories in the current directory, not any lower levels. (Which may be what the OP wants.) It will also break on filenames and directory names with spaces (or tabs) in them.

                                          – wfaulk
                                          May 10 '12 at 22:48

















                                        This will change only files and subdirectories in the current directory, not any lower levels. (Which may be what the OP wants.) It will also break on filenames and directory names with spaces (or tabs) in them.

                                        – wfaulk
                                        May 10 '12 at 22:48





                                        This will change only files and subdirectories in the current directory, not any lower levels. (Which may be what the OP wants.) It will also break on filenames and directory names with spaces (or tabs) in them.

                                        – wfaulk
                                        May 10 '12 at 22:48


















                                        draft saved

                                        draft discarded




















































                                        Thanks for contributing an answer to Server Fault!


                                        • 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%2fserverfault.com%2fquestions%2f156437%2fhow-to-chown-a-directory-recursively-including-hidden-files-or-directories%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

                                        As a Security Precaution, the user account has been locked The Next CEO of Stack OverflowMS...

                                        Список ссавців Італії Природоохоронні статуси | Список |...

                                        Українські прізвища Зміст Історичні відомості |...