WordPress Trợ giúp

Reset WordPress file and folder permissions with SSH

For security reasons, files and folders on servers have permissions that determine who can read, write, access, and modify these files and folders. Permissions are presented with numerical values, and, for WordPress, they should be set to 755 for folders and 644 for files (in older Web Hosting accounts and Managed WordPress, these values are 705 for folders and 604 for files). Insufficient permissions can cause errors on the site and when their values are wrong, it can be a potential security risk. If you want to find out more about the meaning behind these values, you can check out this article on wordpress.org. Here’s how to reset permissions through SSH using BASH commands.

Required: You'll need an SSH app to complete these steps. We suggest PuTTY for Windows, or Terminal for macOS.
Warning: Be extra careful and make sure that you are in the correct directory when changing permissions. If you change permissions in the wrong folder on the server, it'll be hard to revert the change and it can cause issues.
Note: Sites hosted on Manage WordPress hosting plans already have the correct permissions set up and they cannot be changed for security reasons.
  1. Connect to your hosting account with SSH.
  2. Use the command ls to list files and folders, and cd and ../ to move through directories until you are in the directory with WordPress installation.
  3. Use the command pwd to find the path to the current folder (directory).
  4. Enter the following commands:
    • To change permissions for folders:
      find /path/to/current/directory/ -type d -exec chmod 755 {} \;
      In the command above, you should replace /path/to/current/directory/ with the actual path from Step 3.
    • To change permissions for files:
      find /path/to/current/directory/ -type f -exec chmod 644 {} \;
      In the command above, you should replace /path/to/current/directory/ with the actual path from Step 3.

You'll see a message confirming the changes were successful.

More info