Knowledge Base
Save up to  70% off.  Start your website today!

How to Change Permissions (chmod) of a File

Permission 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.

This article discusses the following topics:

How to change permissions

You can change your file permissions in many ways.

Using File Manager in cPanel

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. Log in to cPanel. There are two ways to access your cPanel.
    • Option 1: Access your cPanel directly.
    • Option 2: Access your cPanel via your Customer Portal.
      1. Log in to your Customer Portal.
      2. Click Hosting in the left-side menu.

        Customer Portal - Hosting menu

      3. If you have a single hosting package in your account, scroll down to the Quick Links section.

        If you have multiple hosting packages in your account, locate the hosting package you want to manage on the Hosting Packages page, then click its Manage button.

        Hosting tab - Manage button

      4. Under the Quick Links section, click the cPanel button.

        Hosting menu - Quick Links - Launch cPanel

  2. Within cPanel, click File Manager.

    cPanel - File Manager

  3. There are different ways to change the Permission of a file.
    • Option 1: Locate and select the name of the file you wish to change permission. Then click Permissions at the top menu.

      Hostgator File Manager Change File Permissions

    • Option 2: Right-click on the file that you want to change, then select Change Permissions from the list of options.

      HostGator cPanel Change File Permissions

    • Option 3: Double-click the set of numbers under the Permissions column. Make changes to the permission and hit Save.

      HostGator cPanel Change File Permissions

  4. Click the checkboxes to set the correct permissions.
  5. Click Change Permissions.

    Change Permissions


Using FTP

  1. Launch and connect to FTP.
  2. Locate and right-click on the file you want to change permissions.

    HostGator FTP Right-Click File

  3. Select File Permissions, Attributes, or Properties (depending on your FTP client).

    HostGator FTP File Permissions

  4. Set the permissions you want to apply.


Using SSH or a script

This can be done by running the 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.

  Owner Group World

Here are the three types of users.

  • Owner: The owner is you – the person who has access to the cPanel or shell.
  • Group: The group is other people on your server.
  • World: The world is any visitor from the public (think of 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 are able to view your website files. However, there are some files that 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 are equal to 0.


  • 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.

A common concern is using file permissions of 777. HostGator does not allow 777 on files that process server-side (i.e., PHP). However, many scripts require you to change your files to 777.

I can tell you that 755 will work in lieu of 777. You will not need to use 777 on PHP files or folders.

What's the big deal?

The concern is giving writable permissions to Group and World. This allows hackers from the world wide web to edit your files. Thus, the last two digits of file permissions should never be 2, 3, 6, or 7.

The problem is when you install a PHP script, the script needs permission to edit files. Traditionally, PHP is treated as a 'nobody' on the server. Therefore, PHP is treated the same as any unknown visitor and must obey the permissions granted to World.

The solution to this conflict is to treat PHP as the Owner. HostGator has done so by implementing a special PHP security environment known as suPHP (or phpSuExec).

With suPHP, all PHP scripts are allowed the same permissions as the Owner, and outside visitors are still restricted by the World permissions. Therefore, 755 is the perfect number; it allows all actions for PHP and only reading/viewing for potential hackers.

Other formats

Permissions can be expressed in many ways. You have already seen the two-dimensional matrix and the 3- or 4-digit numbers.

However, if you prefer to use the Linux shell (SSH), then file permissions will look like this:


You can ignore the very first character; it represents the file type rather than permissions. Next, you see three letters that represent the Owner's permissions.

  • r = read
  • w = write
  • x = execute
  • - (hyphen) = no permission

The Owner will normally have all three permissions, which are represented by rwx.

The next three characters represent the Group's permissions. Finally, the last three characters represent the World's permissions.

Notice that Group and World do not get writable permission. In place of the 'w' will be a hyphen, meaning that write is definitely not allowed: r-x.

Here are some conversions to consider.

2D Matrix Numerical Representation Linux Representation
error 755 or 0755

error 644 or 0644

error 700 or 0700 drwx------
error 777 or 0777

Not recommended!


Did you find this article helpful?

* Your feedback is too short