chmod 555
chmod 555 sets r-xr-xr-x: the owner, the group and everyone else can read and execute (list and enter a directory), and no one can write to it.
Permission matrix
| Who | Read (4) | Write (2) | Execute (1) | Digit |
|---|---|---|---|---|
| Owner (u) | Yes | No | Yes | 5 |
| Group (g) | Yes | No | Yes | 5 |
| Others (o) | Yes | No | Yes | 5 |
Execute means different things by type. On a file it lets the kernel run it as a program. On a directory it is search permission: entering it (cd) and reaching the files inside by name. Read on a directory only lists names.
| Who | On a file | On a directory |
|---|---|---|
| Owner (u) | Read and run | List, enter and open entries |
| Group (g) | Read and run | List, enter and open entries |
| Others (o) | Read and run | List, enter and open entries |
Facts
| Octal | 555 (0555) |
|---|---|
| Symbolic | r-xr-xr-x |
| ls -l, file | -r-xr-xr-x |
| ls -l, directory | dr-xr-xr-x |
| Equivalent symbolic command | chmod a=rx |
| Default umask that creates it | None of the common umasks; set it explicitly with chmod |
| How Git records a file with it | 100755 (executable) |
| Special bits | None |
When to use it
- Directories whose entries must not change: on Linux, /proc and /sys show as dr-xr-xr-x, and the kernel creates their contents itself.
- Released builds or vendored tools that should never be edited in place; a write-protected tree turns an accidental edit or rm into an error instead of a silent change.
When not to use it
- As protection against the owner or root: the owner can run chmod again at any time, and root ignores write permission entirely.
- Directories an app writes caches or logs into: every write fails with permission denied.
- Plain data files: the file-side twin is 444, without the execute bits.
Commands
chmod 555 release
chmod a=rx release # same resultstat -c '%a %A %n' release # Linux (GNU stat): 555 dr-xr-xr-x
stat -f '%Lp %Sp %N' release # macOS and BSDApplying it to a whole tree
chmod -R would put the same mode on files and directories alike. Set directories to 555 and files to 444 separately:
find release -type d -exec chmod 555 {} +
find release -type f -exec chmod 444 {} +Or in one pass with a capital X, which adds execute only to directories and to files that already had it: chmod -R a=rX release.
Git and the execute bit
Git stores only one permission fact per file: 100755 if the owner execute bit is set, 100644 otherwise. A file with this mode is committed as 100755; the group and others bits never reach the repository. On Windows, or where core.fileMode is false, set the bit with git update-index --chmod=+x.
Frequently asked questions
- What does chmod 555 mean?
- Owner 5 (read 4 + execute 1), group 5, others 5: r-xr-xr-x. Nobody has write.
- Can I delete a file inside a 555 directory?
- No. Creating, deleting and renaming entries needs write on the directory, and 555 has none. Root still can.
- How do I make a 555 directory writable again?
- As its owner, run chmod u+w on it (or chmod 755). Owners can always change the mode of their own files.
Last reviewed by Arielton Oberek.