security 8 min • Published 2024-10-01

Unix File Permissions & chmod: Complete Guide

Understand Linux/Unix rwx file permissions, octal notation, and how to use chmod correctly — with a free interactive permission calculator.

Understanding rwx Permission Notation

Every Unix file has three sets of permissions: Owner (u), Group (g), and Other (o). Each set has three bits: r (read = 4), w (write = 2), x (execute = 1). The symbolic string "rwxr-xr--" means: Owner has rwx, Group has r-x, Other has r--.

Octal Permission Notation

Add the bit values for each set: r+w+x = 4+2+1 = 7. r+x = 4+1 = 5. r only = 4. So "rwxr-xr--" = 754. chmod 755 = rwxr-xr-x. chmod 644 = rw-r--r--. chmod 600 = rw-------.

Recommended Permissions for Web Servers

Directories: 755 (drwxr-xr-x). PHP/HTML files: 644 (rw-r--r--). Upload directories: 755 (never 777). Configuration files with credentials: 600 (rw-------). Shell scripts: 755 if executable. Private SSH keys: 600 (chmod 600 ~/.ssh/id_rsa).

chmod 777 is a Security Risk

chmod 777 grants full read/write/execute to ALL users on the system. On a shared server, any user can modify, read, or execute the file. Any web vulnerability (file upload, path traversal) that results in code execution can target world-writable files. Never use 777 in production.

Try the Related Tools: