chmod FAQ

How to change file permissions in cPanel and with FTP
  1. What does chmod mean and how does it work?
  2. How do I use chmod in cPanel?
  3. How do I use chmod in an FTP client?
  4. Notes

(Screenshots pertaining to some answers can be viewed by clicking on the eyeglasses eyeglasses ©ejm image.)

  1. What does chmod mean and how does it work?
    The chmod command is used to change file permissions on files and folders. Each file has three different permission pieces:
    1. What the owner of the file (in this case you) can do with it
    2. What the other users in the file's group can do with it,
    3. What the whole world (i.e. public access) can do with it.

    Each permission piece is assigned a numeric value, and the combination of the three numbers in the order specified above (e.g. 755) is the whole permission information for the file.

    Each number is determined by the same set of rules. The number for read access is 4, for write access is 2, and for execute access is 1. To combine those permissions simply add the numbers. For example, if you want a file to have read and write access for one piece of the permission, it would be 4 + 2 = 6. No permissions at all is a zero, and full permissions (4 + 2 + 1) is a 7.

    The two most common permission settings are 755 and 644. You've probably seen these before; this will explain them.

    755
    This means the owner of the file has a permission number of 7, other users in the file's group have a permission number of 5, and the world has a permission number of 5. Therefore, the owner can do absolutely anything with the file (4 + 2 + 1 = 7), and both those in the file's group and the rest of the world can read it and execute it (4 + 1 = 5). This is the required permission set required for CGI files in your cgi-bin folder. Also, these are the permissions necessary for folders inside your webspace if you want their contents to be visible at all, without being too loose and allowing write access to anyone besides you.
    644
    This means the owner of this file has a permission number of 6, other users in the file's group have an access number of 4, and the world has an access number of 4. Therefore, the owner can read and write the file (4 + 2 = 6), and both those in the file's group and those on the outside can only read it. This is the default for files that are uploaded to your webspace at Crosswinds, and is fine for almost all other files outside of CGI files.
    Caveats: Permissions such as 666 and 777, which give full write access or full write and execute access to both those in the file's group, and to the world at large, are not permitted because they are a security risk. That last number especially should not be higher than a 5 for any reason. Also, it's a good idea to keep that first number a 6 or a 7, otherwise you may lock yourself out of being able to do anything with your own file because you won't have enough permissions!

  2. How do I use chmod in cPanel?
    In the cPanel File Manager, you can see all the permissions in numeric format for all your files and folders. For folders, it's simply the only thing all the way to the right on the same line as the folder name. For files, you will see both the file size and the file permissions, in that order, to the right of the file name on the same line.

    To chmod a file:
    1. Click on the file's name.
    2. Click "change permissions" in the top right box on the page.
    3. In the top right box, you will get a bunch of checkboxes grouped by the type of permission as rows and who gets that permission as columns.  eyeglasses ©ejm  Check the boxes for the type of permissions you want each section to have. The sections are labeled "user" (this is you, the owner), "group", and "world".
    4. Click the "Submit" button.

    The file will now have the permissions you filled in.
    Note: Do not fill in the numbers by hand in their boxes. This is because the File Manager only uses the checkboxes to set the permissions; it will not change those checkboxes if you type a number into the permission fields.

  3. How do I use chmod in an FTP client?
    This section describes how to use the chmod command in many commonly used FTP clientsª.

    To chmod a file:
    1. Click the file to highlight it.
    2. Right-click the file and choose "chmod (UNIX)" (Depending on your FTP client, this may also be labelled something like "File Attributes" or "File Permissions".)  eyeglasses ©ejm
    3. You will get a new window with checkboxes grouped by the type of permission as rows and the who gets that permission as columns, very similar to the grid shown in the cPanel File Manager. Fill in the checkboxes the same way as described above. The window may or may not show you the resulting numbers, depending on your own client software.
    4. Click "OK."

    The file will now have the permissions you filled in.

  4. Notes
    The concept of groups is so that several users can be assigned to a specific group, and then a file that belongs to that group can have a specific set of permissions for everyone in that group. It's an easy way to provide more access than just what the file owner can do with a file, but without granting access to all and sundry which would be a security problem.

    Execute access is permission to run the file. This is why CGI files need it. Folders need it because looking into a folder to view what is inside also requires execute access. Files such as images don't need to be run on the server, so they will never need that permission.

    ª For a (non-exhaustive) list of free FTP clients we use and recommend, see this page.