Linux file permissions are one of those things that looks cryptic until someone explains it clearly. Let me be that person.
What Does chmod 755 Actually Mean?
Every file on a Linux system has three sets of permissions:
- Owner (the user who created it)
- Group (users in the same group)
- Others (everyone else)
Each set can have three permissions:
- r = read (value: 4)
- w = write (value: 2)
- x = execute (value: 1)
The number 755 breaks down as:
- 7 = 4+2+1 = read + write + execute (owner gets full access)
- 5 = 4+0+1 = read + execute (group can read and run)
- 5 = 4+0+1 = read + execute (others can read and run)
Common Permission Numbers
| Number | Meaning | Use Case |
|---|---|---|
| 755 | rwxr-xr-x | Web directories, scripts |
| 644 | rw-r--r-- | Regular files, HTML |
| 600 | rw------- | Private keys, secrets |
| 777 | rwxrwxrwx | Avoid! Totally open |
| 400 | r-------- | Read-only sensitive files |
| 750 | rwxr-x--- | Group-restricted scripts |
Symbolic vs Numeric Mode
You can also use symbolic mode:
chmod u+x script.sh # Add execute for owner
chmod g-w file.txt # Remove write for group
chmod o=r file.txt # Set others to read-only
chmod a+r file.txt # Add read for all
Recursive Permissions
To change permissions for an entire directory:
chmod -R 755 /var/www/html
The -R flag applies the permission recursively to all files and subdirectories.
Setting Web Server Permissions
For a typical web server (Nginx/Apache):
# Directories
find /var/www/html -type d -exec chmod 755 {} \;
# Files
find /var/www/html -type f -exec chmod 644 {} \;
# PHP files that need write access
chmod 664 /var/www/html/uploads/
Use a Visual Calculator
If you find the math confusing, use the free CHMOD Calculator at Impeccify. Just check the boxes for the permissions you want and it gives you the number automatically.
It also shows you the symbolic representation and explains what each permission allows.
Top comments (0)