Every file and directory on your hosting account has permissions that determine who can read, modify, or execute it. In most cases, permissions are assigned automatically and do not require manual changes. However, there may be situations where you need to modify permissions-for example, when troubleshooting a website, securing files against modification, or allowing an application to write data to a specific directory.
Table of Contents
Contents
- Understanding Permission Codes
- Default Permission Values
- Changing Permissions via SSH
- Changing Permissions via FTP
Understanding Permission Codes
Permissions can be displayed in two formats:
- Text format (e.g.
rwxr-xr-x) - Numeric format (e.g.
755)
Each permission consists of three possible actions:
| Permission | Meaning |
|---|---|
| r | Read |
| w | Write |
| x | Execute |
Permissions are assigned separately to:
- Owner
- Group
- Others
Text Format Example
rwx rwx rwx This means:
- Owner: Read, Write, Execute
- Group: Read, Write, Execute
- Others: Read, Write, Execute
Full access for everyone.
Another example:
rw- r-- r-- This means:
- Owner: Read and Write
- Group: Read only
- Others: Read only
Only the owner can modify the file.
Understanding Numeric Permissions
Numeric permissions are based on the following values:
| Permission | Value |
|---|---|
| Read | 4 |
| Write | 2 |
| Execute | 1 |
You add the values together to create a permission number.
Example: 777
4 + 2 + 1 = 7 Applied to owner, group, and others:
777 Equivalent to:
rwxrwxrwx Example: 644
6 = 4 + 2
4 = 4
4 = 4 Equivalent to:
rw-r--r-- Recommended Default Permissions
Files
The recommended permissions for files are:
644 This allows:
- Owner: Read and Write
- Group: Read
- Others: Read
Directories
The recommended permissions for directories are:
755 This allows:
- Owner: Read, Write, Execute
- Group: Read, Execute
- Others: Read, Execute
These are the default permissions recommended for most websites and applications.
Changing Permissions via SSH
Before using SSH commands, ensure SSH access is enabled for your hosting account.
Change Permissions for a Single File
Example:
chmod 644 myfile.php This assigns the recommended permissions to the file.
Change Permissions for All Files
To set permissions 644 on all files within the current directory and its subdirectories:
find . -type f -print0 | xargs -0 -n 1 chmod -v 644 Change Permissions for a Single Directory
Example:
chmod 755 mydirectory This assigns the recommended directory permissions.
Change Permissions for All Directories
To set permissions 755 on all directories within the current directory and its subdirectories:
find . -type d -print0 | xargs -0 -n 1 chmod -v 755 These commands are useful when website files have incorrect permissions after a migration, backup restoration, or manual upload.
Changing Permissions via FTP
You can also modify permissions using an FTP client such as:
- WinSCP
- FileZilla
- Cyberduck
Steps
- Connect to your hosting account using FTP.
- Locate the file or directory you want to modify.
- Right-click the item.
- Select Properties, Permissions, or File Attributes (the exact option depends on the FTP client).
- Modify the permissions using either:
- Checkboxes (Read, Write, Execute)
- Numeric values (e.g. 644 or 755)
- Save the changes.
Most FTP clients also allow permissions to be applied recursively to all files and subdirectories.
Common Permission Values
| Permission | Typical Use |
|---|---|
| 644 | Standard files |
| 755 | Standard directories |
| 600 | Sensitive configuration files |
| 700 | Private directories accessible only by the owner |
| 777 | Full access for everyone (not recommended) |
Security Tip: Avoid using
777permissions unless absolutely necessary. Grant only the permissions required for the application to function correctly.
Summary
File and directory permissions control who can read, modify, and execute content on your hosting account. The recommended default values are:
Files: 644
Directories: 755 Permissions can be changed either through SSH using the chmod command or through an FTP client using the file properties menu. Proper permission settings improve both security and application stability.