This tutorial requires more in-depth writing to be refined enough to be educative. Please run a web search and read Linux " man " pages to understand more before implementation.
As a multi-user system, Linux/UNIX uses defined users and groups, ownership, and permissions to specify who has access to a file or directory.
This is a built-in security measure designed to ensure that only the person with the right privilege can access or modify a file.
cPanel is a Linux-based system.
So, you will expect the same rules to apply.
For your website directories and files in cPanel to be able to behave as expected, they must have the right permissions and ownership.
When a file has incorrect permission, the website might not load properly or the application might crash.
Files and directories in Linux have the following three permissions for all three kinds of owners:
For files:
- Read: can view or copy file contents
- Write: can modify file content
- Execute: can run the file (if it is executable)
For directories:
- Read: can list all files and copy the files from a directory
- Write: can add or delete files into a directory (needs execute permission as well)
- Execute: enter the directory using the cd command
You can see this with the "ls" when using the command-line interface:
ls -al
-rw------- 1 username username 1086 Aug 26 06:14 .bash_history -rw-r--r-- 1 username username 18 Aug 30 2021 .bash_logout -rw-r--r-- 1 username username 141 Aug 30 2021 .bash_profile -rw-r--r-- 1 username username 376 Aug 30 2021 .bashrc drwx------ 3 username username 273 Oct 30 12:03 logs drwxr-x--x 5 username username 200 Apr 12 2022 mail --- truncated ---
You can also use the stat command which lists important attributes of the files, and directories and also display information on the filesystem, instead of the files.
stat public_html
File: public_html Size: 4096 Blocks: 8 IO Block: 4096 directory Device: 10302h/66306d Inode: 1652570144 Links: 12 Access: (0750/drwxr-x---) Uid: ( 1032/ $username) Gid: (65534/ nobody) Access: 2022-10-30 07:01:31.300407834 +0000 Modify: 2022-10-27 21:27:26.498114504 +0000 Change: 2022-10-27 21:27:26.498114504 +0000 Birth: 2021-08-30 22:38:36.741992151 +0000
We are assuming that you have successfully created a new web hosting account.
We also assume that you have logged in to your brand-new cPanel hosting panel interface.
With these done, scroll to the Files section and click on the File Manager icon.
When the page loads in a new tab, select the Permissions option from the toolbar.
To set new permissions for the user, group, and world (others), check or uncheck read, write, and execute.
But this works if you are modifying a single file or folder.
What if you have migrated or moved old website files to your new cPanel hosting account and want to ensure that the file and folder permissions are right?
You can modify the directory permissions with
find /home/$username/public_html -type d -exec chmod 755 {} \;
You can modify the modify file permissions with
find /home/$username/public_html -type f -exec chmod 755 {} \;