A basic rule for Drupal files and directories:
- directories : root root drwxr-xr-x (755)
- files : root root rw-r–r– (644)
EXCEPTIONS:
- sites/default/settings.php root root -r–r–r– IMPORTANT : This file must be secured
- sites/default/files – www-data www-data drwxr-xr-x NOTE : Owned by www-data, default php user/group, used by file upload.
You should be able to change all permission from the root directory with the following commands.
Change permission on directories:
find . -type d -exec chmod u=rwx,g=rx,o=rx {} \;
Change permission on files:
find . -type f -exec chmod u=rw,g=r,o=r {} \;
Then take care of the exceptions individually.