Changing File Permissions in cPanel
Each and every file and folder in cpanel Linux hosting account has permissions, which command who all can read, write or execute that particular file or folder. When you create the files these permissions will assign automatically. Mostly as a user, you will not need to modify those permissions, although there are few circumstances when any update, setup-installation etc. need a file or folder permissions to need to be changed.
Here you will be provided with the information to run some form of Linux. Here you will be provided with the information on the basics of file permissions. Here the concept discussed must be applicable to most Linux systems which includes the Grid and Server.
Why file permission is important?
The proper type of file permissions is an extremely important part of ensuring that the website is secure.
Determining the correct form of file permissions for a specific file requires to know what type of information is contained in the file as well as the purpose of that information. There are some guidelines that need to be followed which reside in a web-accessible location.
File permissions are based on three categories on a Linux based system in a web hosting service:
- User - It is a specific account of the hosting system. You can think of it as general as the person who has uploaded or created the file.
- Group - It refers to the specific selection of one or more user. Each user belongs to a default group.
- Other - It refers to any other account on the hosting system.
Here each of these categories can be granted the access in performing the actions on the file:
- Read - It is an ability by which one can view the contents of the file or the directory.
- Write - It is an ability by which one can change the contents of the file or the directory.
- Execute - It is an ability to ask the server for treating the file as a program.
One should never allow more access to the file that is absolutely necessary.
What is the required permission for files and folder?
In cpanel, the files should have 644 permission and folder should have 755 permission.
The users whom the directory or folder belongs to should have write access. Apart from it everyone else must be having the read and execute permissions.therefore the folder permission should be 755
Documents, videos, images and audio files each of it belongs to the category of static content. Here the extensions of the file can indicate that it is static content. The list of some of the extensions which indicate that the file is a static content are: .html, .htm, jpeg, .jpg, .gif, .png, .css, .js, .mpeg, .mgp, .mp3, .avi, .txt, .doc and .pdf
Only the users with who the static content file belongs to should be having the write access. Apart from it, everyone else should be having the read permissions. Execute permissions are not harmful but the following rule is least permissive and hence it is not granted the access. hence the file should have 644 permission
The scripts or the binaries which run on the server and generate the web pages fall into the category of dynamic content. If WordPress or some other content is being used for blogging then it falls into this category. Some of the extensions indicating the dynamic content are shown below: .php, .php4, .php5, .cgi, .pl, .py and .rb
For the user, a dynamic content file belongs to the person who is having the read, write as well as execute permissions. No one else should be having any other permissions. Here the rules of the least permissive are extremely important when it comes to running these types of files as are often containing sensitive information such as a database password. So the file permission for script files will be 700 (only one person permission to read,write, execute)
You can change the file permission in SSH using the below commands:
To change folder permission:
chmod 755 <folder_name>
Ex: chmod 755 wp-content
To change file permission:
chmod 644 <file_name>
Ex: chmod 644 index.html
To change permission for script files:
:chmod 700 script.php
Steps to Change the file permissions using Cpanel:
Step 1: Login into C-panel >> go to file manager
Step 2: You can view the File Permissions in cPanel as shown below. File/folders permissions can be easily viewed or modified through cPanel’s file manager option or from any FTP programs
In the screenshot given above, you can see the permissions of each file and folder in the right-hand side of the screen. One of the most important things you need to remember is that specific files and folders must be set to particular permission. For example:
Folder - 755
.html and .php - 644
public _html - 755
CGI and Perl scripts - 755
Step 3: If the file does not have appropriate permission then you to Change file Permission Setting. You can change the files and folders permission through the cpanel file manager option. In the File Manager, go to the file you want to change the permission to >> hit right click of your mouse in that particular file
Step 4: choose change permissions from the menu as shown in the screenshot below:
Step 5: You can easily change the permission window where you can easily alter the setting as you want by checking or unchecking the boxes next to the permissions.
Step 6: Once you are done with adjusting permissions, click the Change Permissions button.
Note :
You should only change permissions if it is needed and make sure you are not permitting additional access to your valuable files and folders that is essential because doing that can leave your web page unprotected.
If you are looking more information or need additional help related to this, feel free to contact our support team. you can contact us at http://www.hostingraja.in/support/