All files on UNIX (including Linux and other UNIX variants) machines have access permissions. In this way, the operating system knows how to deal with requests to access the files. There are three types of access:
- Read - Denoted as r, files with reading access can be displayed to the user.
- Write - Denoted as w, files with write access can be modified by the user.
- Execute - Denoted as x, files with execute access can be executed as programs by the user.
Access types are set for three types of user group:
- User - The owner of the file.
- Group - Other files which are in the same folder or group.
- World - Everyone else.
The web server needs to be able to read your web pages in order to be able to display them in a browser. The following permissions need to be set in order for your website to function properly.
- All HTML files and images need to be readable by others. The value for this is 644 (readable by User, Group, and World, and writable by User). It is set automatically when you upload files.
- All folders need to be executable by others. The value for this is 755 (readable by User, Group, and World, writable by User, executable by User, Group and World). It is set automatically when you create a folder.
- All CGI files (all files in the CGI-bin folder) need to be executable by other. The value for this is 755 (readable by User, Group, and World, writable by User, executable by User, Group, and World). It is not set automatically when you upload files. You need to change file permissions manually.
Changing file and folder permissions is a crucial task for controlling access and ensuring security on your web server. Here's how you can change file and folder permissions using cPanel's File Manager:
- Login to your cPanel account.
- Click on “File Manager” in the file section.
- Select the directory or file in which you want to change the permissions. Then, right-click and choose “Change Permissions.” Alternatively, you can click on the “Permissions” icon located in the File Manager toolbar. Modify Permissions:
- In the Change Permission window, you will be able to see three types of user options: owner, group, and others.
- You can modify the permissions by selecting the read, write, and execute options.
- Another method to change permissions is by using numeric values like “755” (which represents read, write, and execute for the owner, and read and execute for the group and others).
- Once you are done with the changes you need, you can click the change permissions button and then confirm to complete this process.
- You can verify the permission by checking the permission column in the file manager.
Make sure the change permission setting is done correctly. Improper permissions may lead to errors and vulnerabilities. In general, the most commonly used permission settings are 644 and 755.
- 644 for files (read for everyone, write for owner only)
- 755 for folders (read, write, and execute for owner, read and execute for group, and others)
Always ensure that you set the permissions according to your application's requirements and adhere to security best practices.