DECEMBER 30, 2017 5 MINS READ
One of the most common issues WordPress users face when they recover their WordPress websites or installing new WordPress theme is the file permission errors. WordPress is one of the best CMS which is becoming more secure nowadays, but still we have to manually set some manual guidance.
Some of the permissions are needed to be kept secure, you can’t leave all the permissions open for all. In this post we are going to see some basics of file permissions and how to change the file and folder permissions in the WordPress.
How File and Folder Permissions Work
To make it more easy to understand, the WordPress is the layer between the end user and your database files in the server. By default as the owner you can access the files and folders in your database, but to let the WordPress use the database on the server you have to give permission for it.
The three main functions of the file management are read, write and execution. WordPress does all of these based on the user role and the rules it is been instructed. To make the file permission more machine-friendly here values are set for each function as follows,
- Read – 4
- Write – 2
- Execution – 1
When the value is 6 the function to be executed is read and write. In the same way when the value is 3, the function is write and execute. It is as simple as that.
As like the value arrangement for the functions, a hierarchy order is followed in the user role. Mostly three digit architecture is followed in the file permissions. For example, you might have seen in other blogs to set the file value as 644.
Let us give place value to the three digit number like we do in our schoolings.
- The ones position is for the public, everyone can access the file and folder
- The tens position is for the authorized group of people. The group is selected by the owner
- The hundreds position is for the owner i.e the main admin of the system.
Breaking Down The Values
Now from our example value 644, let us break down the user role and their functions.
[table][thead][tr][th]Number[/th][th]Function[/th][th]User[/th][th]Result[/th][/tr][/thead][tbody][tr][td]6[/td][td]4+2 i.e. read + write[/td][td]Admin[/td][td]Admin can read and write the corresponding files[/td][/tr][tr][td]4[/td][td]4 i.e. read[/td][td]Group[/td][td]Group members can read the files[/td][/tr][tr][td]4[/td][td]4 i.e. read[/td][td]Public[/td][td]Public can read the files[/td][/tr][/tbody][/table]
Now you may get some idea of how the file and folder permissions work and how they are used by different users.
[pro_tip title=”Points To Remember”]
Changing File and Folder Permissions
The file permission can be changed easily from the cPannel. Login to your server cPannel and get to the file directory where your WordPress files and folders reside. As said before for all folders and subfolders we need to set the permissions as 755and for all files as 644. For the wp-config.php the permission should be 660.
Now select the folders in the root directory and right click to get the options. In the right click, option select the “File Permissions” option. In the “Change File Attributes,” dialog box set the numeric value as 755. Make sure you have check marked the “Recurse into subdirectories” and select the radio option “Apply to directories only”.
After setting the permissions for the folder now we have to set permissions for the files in the folders. For that again select the folders in the root directory, along with it also select the files in the root directory this time. Now right click and select the option “File Permissions”. Now set the value as 644. But this time select the radio button option “Apply to Files only”.
Using FTP Terminal
If you are a person who will not be contented without fixing things with code lines, then this method is for you. We are going to use the chmod command to change the file and folder permission mode.
sudo find type f – this code searches for all the available files in your database and changes the value to 644
sudo find type d – this code searches and select the folders in your database and change the permissions to 775.
That’s All Folks
These are the most common methods you can use to change the file and folder permissions in WordPress. Obviously, the cPannel method is the easiest way among these two methods. When you give permission just make yourself clear the user role and the files that they need to access. In simple the admin can have the access to all the files and folders; the group can access internal files, and the public can access the end product file.
That’s it for the 2017!! Hope you guys find this post useful, see you in another post. Wishing you fellas a great year ahead.