How to fix file permissions in Mac OSX and Linux (files to 644 and directories to 755)

I run into this problem when developing on a GIT repository where file permissions change and GIT (correctly) warns of hundreds of changes.  I see this most commonly when importing files from Windows, but it can happen in many different ways.  The fix is to recursively update file permissions. 

To fix all the directories starting from the current one, run:

find . -type d -exec chmod 775 {} \;

To do the same for files, run:

find . -type f -exec chmod 644 {} \;

You can also specify the directory that `find` should start from, e.g.:

find ~/Documents/localdev/test/* -type d -exec chmod 755 {} \;

This will search the contents of the `~/Documents/localdev/test/*` directory and execute the chmod command on any directories within that directory.

Easy!

Tags

Add new comment

This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.