How to Chown a directory recursively including hidden files or directories

chownunix

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

Best 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.

Related Topic