Changing file Ownership Permissions for Lots of Files

Today I was setting up a Cron script to update a site. I’ve been clicking a button on my sites admin page and just wanted it to happen automatically. I ran into a permissions problem when I ran the script. I had dozens of directories and thousands of files to fix. Here is the answer.

To fix Ownership recursively through all the subdirectories:
chown -R user:user /home/user/public_html

Fixing Ownership was easy enough but changing permissions was more tricky since I wanted to do files and directories separately. Here is the answer.

Chmod recursively through all the subdirectories for all files only:
find . -type f -exec chmod 666 {} \;

Chmod recursively through all the subdirectories for all directories only:
find . -type d -exec chmod 755 {} \;

I hope someone finds these commands useful. They got me going today.

This entry was posted in Computers, Servers. Bookmark the permalink.

Leave a Reply

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


(required)*