Permissions can be very important when it comes to hosting your website. Permissions can allow our server computer to write and edit your files. Along with that, some files need to be protected from writing and editing, as a security measure.
You can change your file permissions in many ways.
Using File Manager:
One of the easy and basic ways to change the permissions is through File Manager in cPanel. If you need to make changes to a large number of files, SSH and Cron Jobs are preferable.
To change the permissions for a file or folder in cPanel, please do the following:
- Log into your cPanel.
- Navigate to the Files section and click the File Manager icon.
- Move the document root for your domain name. We have public_html folder in our case.
- You will be able to see the current permissions in the right-hand column called Permissions.
- To make the changes to a certain file/folder, right-click on it and choose Change Permissions.
- 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, Permissions option.
- Or simply by double-clicking on the file permissions in the right-hand column.
Using SSH:
chmod command is used to change the permission of a file. In order to change the permissions of all files and directories in the folder (public_html in our case), follow these steps:
- Connect to your cPanel account via SSH.
- Now you need to navigate to public_html using the following command.
cd /home/username/public_html
- Make sure that you replace username with the actual cPanel username of yours.
- Run one of the commands below for changing permissions to 0755 for the folders and 0644 for the files.
find -type f | xargs chmod 644 ; find -type d | xargs chmod 755 ; chmod 750 . -c
OR
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 {} \;
- Once done, you will see the list of the files and folders which permissions were corrected.
Using FTP:
When uploading to the Internet, you might consider setting attributes for files stored on an FTP server. They include Read, Write, and Execute permissions for your own account as well as others who may visit the FTP site. By not setting the proper permissions, you may prevent access to the files by other users or inadvertently allow unknown users access to your stuff.
To set permissions for a file, follow these steps:
- Connect to FTP. using FTP client software like FileZilla.
- Go to file and right click to open option list.
- Choose Permissions or Attributes or Properties (depends on your program).
Change it according to your requirement and save it.