Sometimes plugins or other features can mess up the permissions for a file or directory(folder) on your site and make it impossible for you to access something or upload something. The easiest way to fix this is with SSH access. If you do not have SSH access, contact your host and see if they allow it and can enable it for you.
To get SSH access enabled on BlueHost, see: http://helpdesk.bluehost.com/index.php/kb/article/000180
You can use the following two lines to reset your permissions. Note that the default directory permissions are 755 and the default file permissions are 644, so that is what I will show here, however, if your webhost says you need other permissions for something, then you can change the numbers. Beware of 777 permissions though, as they are a security threat! If you are told to use 777, first try it with 755 and 644, if that doesn’t work, then carefully add 777 permissions only where you need it.
Here are the SSH commands to fix your permissions on a mass level:
find ~/public_html -type d -exec chmod 755 {} \;find ~/public_html -type f -exec chmod 644 {} \;
Basically, the format is to find, or look, in the path of ~(which means home) and then in public_html. (If you want to look in a different directory, you can change this. e.g. ~/public_html/myblog) And then it looks for the document type, be it directory (d) or file (f), and executes the chmod(change mode) command to change the permissions on all results.
Be very careful with these commands!
If you accidentally break something, it can be difficult to fix. For example, if you have cgi or perl files, they will need 755 permissions instead of 644 in order to operate properly. If you have questions in regards to this, you might want to ask first.




5 Comments until now
perfect. I have bluehost and already had ssh enabled. then I was able to use cyberduck ftp on mac to send the commands to the server. I edited the path to only change the permissions on the folder I wanted. thanks again
Need to bookmark this page. Thanks… worked perfectly after committing a FUBAR on my permissions.
Could you be more specific? Which folders in WP should get what permissions?
Same idea, only slightly better for cgi and perl files, takes a lot longer to run.
find public_html/ -type d -exec chmod 755 {} \; ; find public_html/ -type f -exec chmod 644 {} \; ; find public_html/ -name \*.cgi -exec chmod 755 {} \; ; find public_html/ -name \*.pl -exec chmod 755 {} \; ; find public_html/ -name \*.pm -exec chmod 755 {} \; ; find public_html/ -name .ftpquota -exec chmod 600 {} \;
Very true. And if you wanted it to be faster and not stat every node, you could run commands similar to the ones above, but with find2perl, like this:
find2perl ./ -type d | perl | xargs chmod 755; find2perl ./ -type f | perl | xargs chmod 644; find2perl ./ -name \*.cgi | perl | xargs chmod 755;
etc.
Add your Comment!