How to change permission on all files in a folder and its subdirectories in Linux OS

Today I got a call to be notified that a Joomla-powered website went down. The error message is the core file could not be opened due to permission. I checked the file system and found all PHP files had been changed permission as 200 (User Write only). I don’t know why caused it, but I believe it did something with the mal-ware alerted by Google Webmaster tool yesterday.

Anyhow, the first thing for me now is to change the permission back. I need to change thousands files permission to 644 (rwxr–r–). I will not do it one by one, so I use SSh shell and run the following command:

chmod -R 644 ./sitename

But the above command only changed the folder permission which cause me a lot of trouble which made me a while to change back. So be aware! Then I tried the following:

chmod -R 644 ./sitename/*.*

It worked in someway, it did changed all files under the folder of “sitename” but not the sub-directories. Finally, I used the following command, and it worked.

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

Leave a Reply

Your email address will not be published. Required fields are marked *

Please Answer: * Time limit is exhausted. Please reload the CAPTCHA.