How to correct directory and file permissions for WHM/cPanel servers


There are times, after a migration for example, you will need to set the permissions on every file and directory that has been migrated to a cPanel server.

You could do this many ways running chown on everything to 755 - then setting each file to 644.

there is one easy way to achieve this with the following linux command. You can copy and paste the command and then hit enter:


* Log into the server via SSH (using putty in Windows)

* Change into the public_html directory of the cPanel account you want to modify

* run the following command:
find . -type d -exec chmod 755 {} \; && find . -type f -exec chmod 644 {} \;

This will change each directory under public_html to the Read/Write/Execute, Read/Execute, Read/Execute. 

It will also change each file to Read/Write, Read, Read.

This will help secure the site against unwanted attacks.

Have more questions? Submit a request