Linux / UNIX: Change File Permissions Recursively (conditional)
To find all files in /home/user/demo directory, enter:
find /home/user/demo -type f -print
To find all files in /home/user/demo directory with permission 777, enter:
find /home/user/demo -type f -perm 777 -print
Finally, apply new permission using the -exec option as follows:
$ find /home/user/demo -type f -perm 777 -print -exec chmod 755 {} ;
To select directories and subdirectories use the following syntax:
$ find /var/www/html -type d -perm 777 -print -exec chmod 755 {} ;