How to change permissions for files and directories

0

chmod

This command changes the permission of a file. In order to change the permissions of all files and directories in the public_html/ folder first of all you need to hange the current working directory to /home/username/public_html using the following command:

cd /home/username/public_html

After that run one of the commands below for changing permissions to 0755 for the folders and 0644 for the files:

find -type f | xargs chmod 644 ; find -type d | xargs chmod 755 ; chmod 750 . -c

or

find ./ -type f -not -perm 644 -not -name “.ftpquota” -exec chmod 644 -c {} \;; find ./ -type d -not -perm 755 -not -group nobody -exec chmod 755 -c {} \;

Do not forget to change username to your actual cPanel username. For more information about chmod command use man chmod.

Also, it is possible to change the permissions of all files and directories in the public_html/ using Cron Jobs menu in cPanel. You will need to set up a cron job with one of the following commands:

cd /home/username/public_html ; find -type f | xargs chmod 644 ; find -type d | xargs chmod 755 ; chmod 750 . -c

or

cd /home/username/public_html ; find ./ -type f -not -perm 644 -not -name “.ftpquota” -exec chmod 644 -c {} \;; find ./ -type d -not -perm 755 -not -group nobody -exec chmod 755 -c {} \;

The username should be replaced by your cPanel username as usual.

About Author

Leave a Reply

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