HomeWordPressCorrect Permissions for WordPress Files and Directories

Correct Permissions for WordPress Files and Directories

Setting the right file permissions for your WordPress files and directories is crucial for maintaining its security and functionality. Incorrect permissions can leave your site vulnerable to hackers or cause issues with running WordPress. This guide will walk you through the correct permissions for WordPress files and directories via cPanel and Linux shell.

Before you read this tutorial, please checkout: Linux Permissions Explained

WordPress Directories

For WordPress directories, the recommended permission is 755.
In other words; the owner can read, write, and execute. The group and other users can read and execute.

To set this permission for all WordPress directories via Linux shell, you can use the “find command“:

find /path/to/your/wordpress/ -type d -exec chmod 755 {} \;

Replace the “/path/to/your/wordpress/” with the exact path of your WordPress installation.

Example Screenshot:

To set 755 permission via cPanel;

Locate the “File Manager” option in the “Files” section on your cPanel account followed by navigating to the directory where your WordPress installation is.
Then right-click on the directory you need to change permission (e.g., wp-content, wp-includes).
Select “Change Permissions.” from the popup and set the permissions to 755. After all, click “Change Permissions.”

WordPress Files

For WordPress files, the recommended permission is 644.
This means the owner can read and write. And group and other users can just read the file.

To set this permission for all files using a Linux shell, you can use the following command:

find /path/to/your/wordpress/ -type f -exec chmod 644 {} \;

Replace the “/path/to/your/wordpress/” with the exact path of your WordPress installation.

Example Screenshot:

In the same way, we changed permissions earlier for a directory in cPanel, a file permission can be also modified in cPanel:

Locate the “File Manager” option in the “Files” section on your cPanel account followed by navigating to the directory where your WordPress installation is.
Then right-click on the file you need to change permission (e.g., index.php).
Select “Change Permissions.” from the popup and set the permissions to 755. After all, click “Change Permissions.”

Special Files and Directories

There are some files and directories that need different permission settings in order to work correctly and securely.

wp-config.php

The wp-config.php file contains sensitive information about your WordPress installation. It should have stricter permissions.
The recommended permission is 440 or 400
That means the User can have read, write, and execute permissions, and group and others lack any permissions.

Use one of the following commands in the Linux shell to set these permissions:

chmod 440 /path/to/your/wordpress/wp-config.php

OR

chmod 400 /path/to/your/wordpress/wp-config.php

Uploads Directory

The wp-content/uploads directory might need slightly different permissions to allow file uploads.
Typically, 755 should work, but if you encounter issues, you might need to change it to 775 which is supposed to give user and group full permissions (read, write, execute) and other users; read and execute.

chmod -R 775 /path/to/your/wordpress/wp-content/uploads

File and Directory Permissions Table

File/DirectoryPermission
Root directory (WordPress installation directory : usually public_html)755 or 750
wp-admin755
wp-includes755
wp-content755
wp-content/themes755
wp-content/plugins755
wp-content/uploads755
wp-content/languages755
wp-content/mu-plugins755
wp-content/upgrade755
wp-content/cache755
.htaccess644
index.php644
wp-config.php400 or 440
wp-cron.php644
wp-load.php644
wp-login.php644
wp-mail.php644
wp-settings.php644
wp-signup.php644
wp-activate.php644
wp-blog-header.php644
xmlrpc.php644
license.txt644
readme.html644
wp-links-opml.php644
wp-trackback.php644

By setting these permissions, you ensure that WordPress can manage your media files properly while maintaining security.

Also Read:

Scroll to Top