chmod: What Those Three Numbers Mean
When you see chmod 755 script.sh, each digit represents permissions for a different group: owner, group, and others. Each digit is a sum of permission values.
The Permission Values
| Value | Permission | Symbol |
|---|---|---|
| 4 | Read | r |
| 2 | Write | w |
| 1 | Execute | x |
| 0 | None | - |
Add them together: 7 = 4+2+1 = rwx, 5 = 4+0+1 = r-x, 6 = 4+2+0 = rw-.
Reading chmod 755
chmod 755 script.sh
│││
││└── Others: 5 (r-x) — can read and execute
│└─── Group: 5 (r-x) — can read and execute
└──── Owner: 7 (rwx) — can read, write, and execute
# In ls -l output:
-rwxr-xr-x 1 user group 1234 Apr 25 script.sh
│││││││││
││││││││└── Others: execute
│││││││└─── Others: no write
││││││└──── Others: read
│││││└───── Group: execute
││││└────── Group: no write
│││└─────── Group: read
││└──────── Owner: execute
│└───────── Owner: write
└────────── Owner: readCommon Permission Sets
| chmod | Symbol | Use Case |
|---|---|---|
755 | rwxr-xr-x | Executable scripts, directories |
644 | rw-r--r-- | Regular files (HTML, CSS, images) |
600 | rw------- | Private files (.env, SSH keys) |
700 | rwx------ | Private directories, scripts |
777 | rwxrwxrwx | NEVER use in production (everyone can do everything) |
444 | r--r--r-- | Read-only for everyone |
Symbolic Mode
# Add execute for owner
chmod u+x script.sh
# Remove write for group and others
chmod go-w file.txt
# Set exact permissions
chmod u=rwx,g=rx,o=rx script.sh # same as 755
# u=user(owner), g=group, o=others, a=allCalculate permissions: chmod Calculator — click checkboxes, get the numeric and symbolic chmod value.