Using File Manager
Using SSH
Using Cron Jobs

Here’s a step-by-step breakdown of the instructions you provided:

  1. Log into cPanel:
    • Open your web browser and navigate to your cPanel login page. This is usually something like https://yourdomain.com/cpanel.
    • Enter your cPanel username and password to log in.
  2. Navigate to the Files section:
    • Once logged in, look for the “Files” section in cPanel. It may be represented by an icon or a list of options.
  3. Click the File Manager icon:
    • Within the “Files” section, find and click on the “File Manager” icon. This tool allows you to manage files and directories directly from your web browser.
  4. Move the document root for your domain name. We have public_html folder in our case:
  5. You will be able to see current permissions in the right-hand column called Permissions:
  6. To make the changes to a certain file/folder, right-click on it and choose Change Permissions. This window will pop up:
  7. Set required permissions for each user group and save the changes. It is also possible to use the same button in the File Manager upper-bar menu, the Permissions option:
  8. Or simply by clicking on file permissions in the right-hand column:

The provided steps and commands are intended to be executed on a server via SSH to change permissions for files and directories within a specific folder (in this case, public_html). Here’s a breakdown of the steps and commands:

  1. Connect to cPanel Account via SSH:
  • Use an SSH client to connect to your cPanel account. The specific details for connecting may vary depending on your hosting provider. Refer to the documentation or guidelines provided by your hosting service.
  1. Navigate to public_html:
  • Once connected, use the cd command to navigate to the public_html directory. Replace “username” with your actual cPanel username.
    bash cd /home/username/public_html
  1. Change Permissions for Files and Directories:
  • Run one of the following sets of commands to change permissions to 0755 for directories and 0644 for files. Option 1:
   find -type f | xargs chmod 644
   find -type d | xargs chmod 755
   chmod 750 . -c

Option 2:

   find ./ -type f -not -perm 644 -not -name ".ftpquota" -exec chmod 644 -c {} \;
   find ./ -type d -not -perm 755 -not -group nobody -exec chmod 755 -c {} \;
  • These commands use the find command to locate files and directories within the specified path and apply the chmod command to set the desired permissions.
  • For files, chmod 644 sets read and write permissions for the owner and read-only permissions for group and others.
  • For directories, chmod 755 sets read, write, and execute permissions for the owner, and read and execute permissions for group and others.
  • The last command (chmod 750 . -c) in Option 1 is used to change the permission of the current directory (.) to 750.
  • Ensure that you are in the correct directory before executing these commands to avoid unintended changes to permissions in other locations.

Always exercise caution when using the chmod command, especially in production environments, to avoid unintentional security vulnerabilities.

The provided instructions guide you through using the Cron Jobs tool in cPanel to automate the process of changing file and folder permissions. Here’s a breakdown of the steps:

  1. Access Cron Jobs in cPanel:
  • Log in to your cPanel account.
  • Navigate to the Advanced section and locate the Cron Jobs menu.
  1. Set Common Settings and Add Script:
  • In the “Add New Cron Job” section, set the “Common Settings” parameter to “Once Per Ten Minutes.”
  • Add one of the provided scripts to the “Command line.” These scripts use the find and chmod commands to change permissions for files and directories within the specified path. Option 1:
   cd /home/username/public_html && find -type f | xargs chmod 644 ; find -type d | xargs chmod 755 ; chmod 750 . -c

Option 2:

   cd /home/username/public_html && find ./ -type f -not -perm 644 -not -name ".ftpquota" -exec chmod 644 -c {} \;; find ./ -type d -not -perm 755 -not -group nobody -exec chmod 755 -c {} \;
  • Replace “username” with your actual cPanel username.
  1. Add and Remove Cron Job:
  • Click the “Add New Cron Job” button to schedule the cron job.
  1. Wait for Changes:
  • Wait for a couple of minutes for the cron job to execute and make the necessary changes to file and folder permissions.
  1. Remove Cron Job:
  • After the cron job has executed successfully, remove it using the “Delete” option in the Cron Jobs section.

Note:

  • The provided scripts should not be run for the home folder (/home/username) to avoid conflicts with custom permission settings. Changing permissions in the home directory may lead to security issues and conflicts, affecting cPanel functionality.
  • Ensure that you replace “username” with your actual cPanel username.
  • Running cron scripts with intervals of less than 10 minutes is prohibited for shared plans according to the Acceptable Use Policy. Make sure to remove the script once the permissions are updated to comply with the policy.

Similar Posts