Managing File Permissions
Managing File Permissions
File permissions control who can read, write, and execute files on your hosting server. Correct permissions are essential for both security and proper website functionality.
Understanding Permission Numbers
Linux file permissions use a three-digit numeric system (e.g., 755, 644), where each digit represents permissions for a different user group:
| Position | User Group |
|---|---|
| First digit | Owner — The account that owns the file |
| Second digit | Group — Users in the file’s group |
| Third digit | Others — Everyone else (public) |
Each digit is a sum of permission values:
| Value | Permission |
|---|---|
| 4 | Read (r) |
| 2 | Write (w) |
| 1 | Execute (x) |
| 0 | No permission |
Examples:
- 755 = Owner: read+write+execute (7), Group: read+execute (5), Others: read+execute (5)
- 644 = Owner: read+write (6), Group: read (4), Others: read (4)
Recommended Permissions
| File Type | Permission | Numeric |
|---|---|---|
| Directories | rwxr-xr-x | 755 |
| HTML/PHP/JS files | rw-r–r– | 644 |
| Configuration files | rw-r—– | 640 |
.htaccess | rw-r–r– | 644 |
| CGI/Perl scripts | rwxr-xr-x | 755 |
wp-config.php | rw-r—– | 640 or 600 |
| Upload directories | rwxr-xr-x | 755 |
Changing Permissions in cPanel File Manager
- Log into cPanel and open File Manager.
- Navigate to the file or directory.
- Right-click and select Change Permissions.
- Check/uncheck the appropriate boxes or enter the numeric value.
- Click Change Permissions to save.
Changing Permissions via SSH
Single file:
chmod 644 filename.php
Single directory:
chmod 755 directoryname
All files in a directory recursively:
find /home/username/public_html -type f -exec chmod 644 {} \;
All directories recursively:
find /home/username/public_html -type d -exec chmod 755 {} \;
Changing Permissions via FTP
Most FTP clients (like FileZilla) let you change permissions:
- Right-click the file or directory.
- Select File Permissions (or Properties).
- Enter the numeric value or check the appropriate boxes.
- For directories, you can apply recursively to contents.
Common Permission Issues
403 Forbidden Error:
- The web server can’t read the file. Ensure files are at least 644 and directories 755.
500 Internal Server Error:
- Permissions set to 777 can cause this error on some servers. Reduce to 755 for directories and 644 for files.
Files can’t be modified:
- The owner may not have write permission. Set to 644 or 664.
Security Warnings
- Never use 777 permissions. This gives everyone read, write, and execute access — a major security risk.
- Restrict sensitive files like
wp-config.phpor.envto 640 or 600. - Check permissions after uploading — FTP clients may upload with incorrect permissions.
- If a web application asks you to set 777 permissions, look for alternative solutions first.
Checking File Ownership
Via SSH:
ls -la /home/username/public_html/
The output shows owner, group, permissions, and file names. If ownership is wrong, contact 10Corp support for assistance, as changing ownership typically requires root access.
For file permission help, contact 10Corp support.