100% Client-Side: Zero Data Leaves Your Browser
Interactive Chmod Calculator & Permission Generator
Calculate Linux/Unix octal file permissions (e.g., 755, 644, 400), symbolic strings (-rwxr-xr-x), and generate copy-pasteable terminal commands.
| Role | Read (4) | Write (2) | Execute (1) | Octal |
|---|---|---|---|---|
| Owner User (u) | 6 | |||
| Group Group (g) | 4 | |||
| Others Public (o) | 4 |
chmod 0644 /var/www/html/index.php
Understanding Linux File Permissions (chmod)
In Unix-like operating systems (Linux, macOS, BSD), file system permissions control which users can read, modify, or execute files and directories. The chmod (change mode) command alters these permissions using either octal notation (numeric representation) or symbolic notation.
How the Octal Permission Formula Works
Every Linux permission bit represents a power of 2 in binary arithmetic:
- Read (r) = 4 (Binary:
100) — Permission to open and read file contents or list directory files. - Write (w) = 2 (Binary:
010) — Permission to modify, rename, or delete file contents. - Execute (x) = 1 (Binary:
001) — Permission to run a file as a program/script or traverse into a directory.
Examples:
• Read + Write = 4 + 2 = 6
• Read + Execute = 4 + 1 = 5
• Read + Write + Execute = 4 + 2 + 1 = 7
• No Permissions = 0
User Roles in Unix
The 3-digit octal permission represents three distinct authorization tiers in order:
- User / Owner (u): The individual account that owns the file.
- Group (g): The user group assigned to the file.
- Others / Public (o): All other accounts on the operating system.
Recommended Security Best Practices
| Target Resource | Recommended Mode | Security Rationale |
|---|---|---|
| Web Root Folders | 755 (rwxr-xr-x) | Allows web server (nginx/apache) to traverse and read assets without public write access. |
| Standard PHP / HTML Files | 644 (rw-r–r–) | Owner can write; web server and public can read; no execution allowed. |
| Configuration / Secrets | 600 or 400 | wp-config.php or .env files should only be accessible by the owner process. |
| SSH Private Keys | 400 (r——–) | OpenSSH strictly refuses connections if private key permissions are wider than 400 or 600. |
Frequently Asked Questions (FAQ)
Q: Why is chmod 777 dangerous in production?
Mode 777 allows any process or local user on the machine to edit, overwrite, or delete the file. In a web hosting environment, if an attacker uploads a webshell, they can overwrite any 777-permissioned file on the entire server.
Q: How do I change all directory permissions separately from file permissions?
Use the standard Unix find command:
find /var/www/html -type d -exec chmod 755 {} + (sets folders to 755)
find /var/www/html -type f -exec chmod 644 {} + (sets files to 644)
Q: What is the difference between chmod and chown?
chmod changes access permissions (read, write, execute), while chown changes ownership (which user and group own the file).