Skip to main content

Understanding and Setting File Permissions

files, permissions, chmod, security 0 Was this answer helpful?

File permissions control who can read, write, and execute files on your hosting account. Incorrect permissions can make your website inaccessible or, worse, create security vulnerabilities.

Please note: Screens and options may vary slightly depending on your cPanel version and hosting plan.

⚠️ Caution: Incorrect changes here can make your website inaccessible. If you are unsure about any step, please contact our support team before proceeding.

How Permissions Work

Every file and directory has three sets of permissions for three types of users:

  • Owner — The user who owns the file (typically your cPanel account).
  • Group — Users in the same group as the owner.
  • Public (Others) — Everyone else.

Each set has three permission types:

  • Read (r / 4) — View the file contents or list directory contents.
  • Write (w / 2) — Modify the file or create/delete files in a directory.
  • Execute (x / 1) — Run the file as a script, or access a directory.

Permissions are expressed as a three-digit number. Each digit is the sum of the permission values:

| Value | Permissions | |-------|------------| | 7 | Read + Write + Execute (rwx) | | 6 | Read + Write (rw-) | | 5 | Read + Execute (r-x) | | 4 | Read only (r--) | | 0 | No permissions (---) |

For example, 755 means: Owner can read/write/execute, Group can read/execute, Others can read/execute.

Recommended Permissions

| Item | Permission | Meaning | |------|-----------|---------| | Directories | 755 | Owner: full access. Others: read and traverse. | | Files | 644 | Owner: read and write. Others: read only. | | Configuration files (e.g. wp-config.php, .env) | 600 or 640 | Owner only, or owner and group. No public access. | | CGI scripts | 755 | Must be executable. |

Changing Permissions in File Manager

  1. Open File Manager in cPanel.
  2. Right-click the file or folder.
  3. Select Change Permissions.
  4. Tick or untick the permission boxes, or type the numeric value directly.
  5. Click Change Permissions.

Changing Permissions via SSH or Terminal

# Set a file to 644
chmod 644 filename.php

# Set a directory to 755
chmod 755 directoryname

# Recursively set all files in a directory to 644
find /home/username/public_html -type f -exec chmod 644 {} \;

# Recursively set all directories to 755
find /home/username/public_html -type d -exec chmod 755 {} \;

Common Permission Problems

  • 403 Forbidden error — The web server can't read the file. Check that files are 644 and directories are 755.
  • 500 Internal Server Error — A CGI or PHP script may have incorrect permissions. Scripts should be 755. Configuration files should not be world-writable (never 777).
  • "Permission denied" when uploading via FTP — The destination directory may not be writable by the FTP user.
  • Security warning from WordPress or other CMS — Some applications check for overly permissive files. Never use 777 on a production server.

Tips

  • Never set files or directories to 777. This gives everyone full access and is a significant security risk.
  • If an application asks for 777 permissions, check whether your server uses suPHP or PHP-FPM — these run PHP as your user, so 755 for directories and 644 for files should work.
  • Sensitive configuration files containing database passwords or API keys should be 600 or 640.

What Next?

Related Articles

knowledgebasedidyoufindanswer