Change ownership of all folders and subfolders or files
By Mike Street
There are often times the permissions on files get a bit confounded and I wish to change them all the be a certain "number". This is different depending on if they are files or folders (and should never be 777).
Change all directories from the current path
$ find . -type d -exec chmod 775 {} \;
Change all files from the current path
$ find . -type f -exec chmod 664 {} \;
These two commands are a life saver - allowing folders a bit more permission than files so that web scripts can update contents inside. Please be wary of what you set permissions to as it could be dangerous!
This code originates from Stack Overflow