What does it mean to change file permissions cPanel recursively? Does it mean changing file permissions in bulk in cPanel?
Yes, changing file permissions recursively can also be called changing file permissions in bulk on cPanel. However, while we can usually select multiple files directly through the File Manager and then change the permissions, it would certainly be very difficult if there are files inside folders or subfolders that we need to update.
The solution is that we can use a recursive method to change all files, whether they are in the main folder or in subfolders, using Terminal or SSH.
Still don't understand what that means?
For an easy example, let's say we currently have a folder public_html which contains 20 files with permissions 400 (r——–) and 3 folders, and from these 3 folders there are individual files with permissions 440 (r–r—–). Because we need permissions 640 (rw-r—–) or 644 (rw-r–r–) on the files so the website can be accessed, we need to change all those file permissions.
If done manually, it means we would need to open 4 folders to change all the file permissions, which would certainly be very tiring.
How to Recursively Change cPanel File Permissions
Hopefully you understand now. Even if you do not, we will discuss how to change file permissions recursively in cPanel using Terminal or SSH here, so make sure the SSH or Terminal feature in your cPanel is active.
Step 1: Access Terminal or SSH
First, we can open terminal or SSH access using applications like PuTTY or directly from CMD.
If you are using the built-in cPanel terminal, you can search for the Terminal page directly from the cPanel search bar.
If you are using CMD, you can use the following command below
ssh username_cpanel@IP_server -p 22Step 2: Open the Main File Folder
In the previous example, we had a public_html folder and 3 subfolders, so we need to open the main folder, or public_html. However, here, for example, I will open the folder staging.wpgan.com, so the command used is like this
cd /home/username_cpane/staging.wpgan.comStep 3: Recursively Change cPanel File Permissions
Since we are already in the main folder, we can now change all file permissions recursively. To change all files, including php, txt, json, and other files to new permissions, for example 644, we can use this command
find . -type f -exec chmod 644 -R {} \;If we want to change permissions on .php files only, we can use this command
find . -type f -name "*.php" -exec chmod 644 -R {} \;If you want to change folder permissions instead of files, you can use this command
find . -type d -exec chmod 755 {} \;After using one of the commands above, we can check the file and folder permissions using cPanel. For example, if we set the file permissions to 640 and the folder permissions to 750, the results in the file manager will look like this
That is how to recursively change cPanel file permissions. Because this method requires SSH access, it is recommended to try it on a folder that is not used on your live site , so that if there is an error in using the command, it will not directly impact the website.
COMMENTS
Loading...