chmod 550: Programs a Service Can Run but Cannot Change
550 is r-xr-x---: the owner and the owning group can read and execute, nobody can write, and every other account is refused entirely. It is the right mode for a script that a service runs and must never be able to rewrite.
At a glance
- Octal
- 550, written 0550 in four digit form
- Symbolic
- u=rx,g=rx,o=
- On a file
- -r-xr-x---
- On a directory
- dr-xr-x---
- Owner
- Read and execute. No write, even for the owner
- Group
- Read and execute. This is how the service runs it
- Others
- Nothing. Cannot read, cannot run, cannot even see the contents
In detail
550 separates two rights that people habitually give away together: the right to run something and the right to change it. A service account that is a member of the owning group can execute the script and read it, which an interpreter needs, and cannot modify it. A compromised service therefore cannot rewrite its own automation and wait to be run again.
The zero for others matters as much. Scripts leak: they contain hostnames, paths, account names, sometimes an inline credential that should not be there. At 555 or 755 every account on the machine can read all of that. At 550 only the group can, which shrinks the audience for an accidental disclosure to the set of accounts you deliberately chose.
Ownership is what makes it work. The file should be owned by a management account or by root, with the group set to the service, so that deployment changes it by temporarily relaxing the mode or by replacing it as the owner, while the running service never has write permission at all. Owner root with group set to the service account is the common shape.
On a directory, 550 gives the owner and the group the ability to list and traverse but not to create or delete entries. That is a useful pairing: a 550 directory of 550 scripts is a fixed set of fixed programs, where adding a new one is a deliberate administrative act rather than something the service can do to itself.
The trade off is deployment friction, and it is the point rather than a flaw. Any update has to be performed by the owner, which usually means a deploy step that runs as a different account from the service. If that feels awkward, the awkwardness is the security property showing up in the workflow.
Examples
chmod 550 /opt/app/bin/rotate-keys.sh
chmod u=rx,g=rx,o= /opt/app/bin/rotate-keys.shchown root:appsvc /opt/app/bin/rotate-keys.sh
chmod 550 /opt/app/bin/rotate-keys.sh
-r-xr-x--- 1 root appsvc rotate-keys.sh
The service, running as a member of appsvc, executes it.
It cannot edit it. No other account can read it.# as root, the owner
chmod u+w /opt/app/bin/rotate-keys.sh
cp new-version.sh /opt/app/bin/rotate-keys.sh
chmod 550 /opt/app/bin/rotate-keys.shThings that catch people out
- The service account must actually be in the group, and a running process does not pick up a group added after it started. Restart the service after changing membership.
- A shell script needs the read bit as well as execute, which 550 gives to the owner and the group. Removing group read to reach 510 breaks the script for the service while leaving the execute bit misleadingly in place.
- Deploy pipelines that write directly into place will fail against 550. That is intended, but it needs to be handled in the pipeline rather than discovered during an incident.
- 550 protects the script, not the interpreter or the directory. A writable parent directory lets an attacker replace the file wholesale, so set the directory to 550 or 750 as well.
Try it: Chmod Calculator
Tick the nine permission boxes, or type an octal or symbolic value, and get the three digit and four digit octal, the ls -l rendering and the exact chmod command back.
Chmod Calculator
LOCAL · Browser-OnlyCalculate Unix file permissions with an interactive chmod builder
Permission Matrix
| Entity | Read (4) | Write (2) | Execute (1) | Octal | Symbolic |
|---|---|---|---|---|---|
| Owner (u) | 7 | rwx | |||
| Group (g) | 5 | r-x | |||
| Others (o) | 5 | r-x |
Special Bits
Advanced permission flags for executables and directories
Generated Permissions
755rwxr-xr-x-rwxr-xr-xchmod 755 filenamechmod u=rwx,g=rx,o=rx filenamePermission Breakdown
Owner (u)
7rwx- - Read files / list directory contents
- - Write / modify / delete
- - Execute / traverse directory
Group (g)
5r-x- - Read files / list directory contents
- - Execute / traverse directory
Others (o)
5r-x- - Read files / list directory contents
- - Execute / traverse directory
Common Permissions Reference
| Octal | Symbolic | Meaning |
|---|---|---|
777 | rwxrwxrwx | Full access for everyone |
755 | rwxr-xr-x | Owner full, others read and execute |
750 | rwxr-x--- | Owner full, group read and execute |
700 | rwx------ | Owner full access only |
666 | rw-rw-rw- | Read and write for everyone |
644 | rw-r--r-- | Owner read/write, others read only |
600 | rw------- | Owner read/write only |
555 | r-xr-xr-x | Read and execute for everyone |
444 | r--r--r-- | Read only for everyone |
400 | r-------- | Owner read only |
Related File permissions
All file permissions →chmod 555: Read and Execute With No Write for Anyone
555 removes the write bit from the owner as well as everyone else. What that protects against, what it does not, and how real immutability is done.
chmod 750: Owner Writes, Group Reads, Others Shut Out
750 gives the owner everything, the group read and traverse, and everyone else nothing. The right mode for application directories that must stay private.
chmod 500: Owner Only Read and Execute, Nothing Else
500 lets the owner read and execute but not write, and gives group and others nothing. A guard against accidental edits and a way to freeze a directory.
chmod 440: Read Only for Owner and Group, the sudoers Mode
440 gives the owner and group read only and everyone else nothing. Why sudo refuses to run unless its configuration files carry exactly this mode.
chmod 444: Read Only for Everyone, With Real Limits
444 gives read to all three classes and write to none, not even the owner. Why a 444 file can still be deleted and what actually makes a file immutable.
chmod 400: Read Only Keys and Downloaded PEM Files
400 gives the owner read and nothing to anyone else, not even write. The usual mode for a downloaded cloud key pair and how it differs from 600.
Tools for this
- Chmod Calculator Free online chmod calculator - calculate Unix file permissions with an interactive chmod builder