How to change permissions (chmod) of a file Print

  • 32

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. To change the permissions for a file or folder in cpanel, please do the following:

  1. Click File Manager
  2. Click the name of the file for which you would like to change the permissions.
  3. Select the Change Permissions link at the top right of the page.
  4. Select the permissions you would like to set for the file.
  5. Click Change Permissions

Using FTP

Connect to FTP. Go to the file and right click. Choose Permissions or Attributes or Properties (depends on your program).

Using SSH or a script

This can be done with chmod command.


So, what do these permissions and numbers mean?

File permissions determine what you are allowed to do and who is allowed to do it.


OwnerGroupWorld
Read???
Write?

Execute???

The columns are the three types of users. First is the Owner; the owner is you, the person who has access to the cPanel or shell. Second is the Group; the group is other people on your server. Third is the World; the world is any visitor from the public (think world wide web).

Each row represents a permitted action for this file (or folder). Read means the user is allowed to view the file. Write means the user is allowed to edit the file. Execute means the user is allowed to run the file.

It is very important that Group and World be able to view your website files. However, there are some files which you may not want anyone to see. If you remove the check for Read under Group and World, then the file will not show in anyone's browser (instead visitors will see a 403 Forbidden error).

In the File Manager, permissions are expressed as numbers. We are only concerned with 3 digits, so if you see 4 digits, then ignore the first one. Thus 0755 is the same as 755.

The numbers represent a combination of each unique permission. Also, the first of the three digits represents the permissions for the Owner. The second digit represents the Group. The third digit represents the World.

  • Read is equal to 4.
  • Write is equal to 2.
  • Execute is equal to 1.
  • No permissions for a user is equal to 0.

Thus...

  • Write and Execute without Read is equal to 3.
  • Read and Execute without Write is equal to 5.
  • Read and Write without Execute is equal to 6.
  • Read and Write and Execute is equal to 7.

At this point, all you need to know is that your files should always have permissions of 644 or 755. (For most files, it doesn't matter if you give the executable permission or not. You won't see any difference.)

However, folders must always be 755.

One more rule. Any files inside the cgi-bin folder must have 755 permissions.


Was this answer helpful?

« Back