Table of Contents
- What Are File Permissions?
- The Octal System: Reading Permission Numbers
- Permission 755 â What It Means & When to Use It
- Permission 644 â What It Means & When to Use It
- Permission Comparison Table
- Setting Permissions in DirectAdmin
- chmod Commands on VPS
- Common Errors from Wrong Permissions
- WordPress Security Permissions
- Summary
- Frequently Asked Questions
1. What Are File Permissions?
File permissions are a security system that controls who can read, write, or execute files and directories on a Linux server â the same OS that powers all web hosting and VPS environments at AsiaGB.
Linux splits users into three categories:
- Owner â the user who created or owns the file (usually your hosting account)
- Group â a set of users sharing permissions (e.g., the web server group)
- Others â everyone else on the server
And three types of access:
- Read (r = 4) â view file content or list directory contents
- Write (w = 2) â modify, create, or delete files
- Execute (x = 1) â run scripts/programs; for directories: enter the directory
The web server process (Apache/Nginx) must be able to read your web files. Wrong permissions cause immediate 403 Forbidden errors for your visitors.
2. The Octal System: Reading Permission Numbers
Linux represents permissions as a 3-digit octal (base-8) number. Each digit is the sum of Read (4) + Write (2) + Execute (1) for Owner, Group, and Others respectively.
When you run ls -la in a terminal, you see these as letters like drwxr-xr-x â d for directory, then three groups of rwx for Owner/Group/Others.
3. Permission 755 â What It Means & When to Use It
755 translates to rwxr-xr-x:
- Owner: full access â read, write, execute (7 = rwx)
- Group: read and execute, no write (5 = r-x)
- Others: read and execute, no write (5 = r-x)
When to use 755
- â All directories/folders â the web server needs execute permission on directories to access their contents
- â
Executable scripts (
.sh, CGI scripts) - â
Folders like
public_html/,wp-content/,uploads/
If a directory is set to 700, the web server cannot enter it at all â your entire site will show 403 Forbidden.
4. Permission 644 â What It Means & When to Use It
644 translates to rw-r--r--:
- Owner: read and write (6 = rw-)
- Group: read only (4 = r--)
- Others: read only (4 = r--)
When to use 644
- â All regular files â HTML, PHP, CSS, JavaScript, images
- â
index.php,index.html - â All WordPress PHP files (except wp-config.php â use 600)
- â
.htaccess
644 works because the web server (running as group or others) can still read the file to serve it, but cannot modify it â significantly more secure than 777.
5. Permission Comparison Table
| Permission | Symbol | Owner | Group | Others | Use Case |
|---|---|---|---|---|---|
| 644 | rw-r--r-- | Read+Write | Read | Read | Regular web files |
| 755 | rwxr-xr-x | Full | Read+Exec | Read+Exec | Directories |
| 600 | rw------- | Read+Write | None | None | wp-config.php, SSH keys |
| 700 | rwx------ | Full | None | None | Private directories |
| 777 | rwxrwxrwx | Full | Full | Full | â Never use on web files! |
6. Setting Permissions in DirectAdmin
AsiaGB Hosting uses DirectAdmin, which has a built-in File Manager â no terminal needed.
Step-by-step
- Log in to your DirectAdmin control panel (e.g.,
yourdomain.com:2222) - Click Files â File Manager
- Navigate to the file or folder you want to change
- Right-click â select Change Permissions
- Enter the numeric permission value (e.g.,
755or644) and click OK
To change multiple files at once, hold Ctrl and click each file, then right-click â Change Permissions to apply in bulk.
7. chmod Commands on VPS
If you have SSH access to an AsiaGB VPS, the chmod command gives you precise control.
Basic commands
The right way: set files and directories separately
The safest approach for WordPress is to use find to set directory and file permissions independently in one pass:
chmod -R applies the same value to both files and directories. Using find -type d and find -type f separately ensures directories get 755 while files get 644 â the correct combination.
8. Common Errors from Wrong Permissions
403 Forbidden
The most common symptom of permission errors. The web server can't read your files.
| Problem | Wrong Permission | Fix To |
|---|---|---|
| 403 on entire site | public_html = 700 | 755 |
| 403 on index page | index.php = 600 | 644 |
| 403 on images | uploads/ = 700 | 755 |
| PHP write error | uploads/ = 555 | 755 |
Hacked Site / Shell Upload
The #1 root cause is directories or upload folders set to 777. Attackers upload a PHP web shell through a file upload form and gain full control of your server.
Never set any web-accessible file or directory to 777. The uploads/ directory is the most common attack vector â an attacker can upload a PHP shell and execute arbitrary commands on your server the moment it goes 777.
9. WordPress Security Permissions
Here is the complete recommended permission setup for a WordPress site:
| File / Directory | Recommended | Reason |
|---|---|---|
| public_html/ | 755 | Web server must access |
| All PHP files | 644 | Readable, not writable by server |
| wp-config.php | 600 | Contains DB password â max security |
| wp-content/ | 755 | WordPress must write plugins/themes |
| wp-content/uploads/ | 755 | Allow uploads but not 777 |
| .htaccess | 644 | Apache reads it; no one else writes |
Summary
- 755 â for all directories; lets the web server enter them
- 644 â for all regular files; web server can read, nobody writes except owner
- 600 â for sensitive config files like wp-config.php
- 777 â never use on web files; it opens a shell-upload backdoor
- Use
find -type dandfind -type fseparately to apply the correct permissions in one shot - DirectAdmin File Manager lets you change permissions visually without SSH
Frequently Asked Questions
Is permission 777 dangerous?
Extremely dangerous. It grants full read/write/execute to everyone on the server. Attackers exploit this to upload PHP shells and run arbitrary commands. Never use it on any web-accessible location.
What permissions should WordPress files use?
Set all directories to 755 and all files to 644. Set wp-config.php to 600 since it holds your database credentials.
Why am I getting a 403 Forbidden error?
Your directory is likely set to 700 (blocking the web server) or your index file is 600. Fix: set directories to 755 and files to 644.
Can I change permissions in DirectAdmin without SSH?
Yes. In DirectAdmin â Files â File Manager, right-click any file or folder â Change Permissions â enter the numeric value and click OK.
What is the difference between 644 and 640?
644 lets others (including the web server process) read the file. 640 denies all access to others. Use 644 for regular web files and 600 for sensitive config files.
How do I set permissions for all files and directories at once?
Use: find . -type d -exec chmod 755 {} \; for directories and find . -type f -exec chmod 644 {} \; for files. This correctly applies different values to each type, unlike chmod -R which uses the same value for both.