chmod 007: Everyone Else Gets Everything, the Owner Gets Nothing
007 is -------rwx: every account that is neither the owner nor in the owning group gets read, write and execute, while the owner and the group get nothing. It is almost always a mistyped 700 and it is the worst of both worlds.
At a glance
- Octal
- 007, written 0007 in four digit form
- Symbolic
- u=,g=,o=rwx
- On a file
- -------rwx
- On a directory
- d------rwx
- Owner
- Nothing. Locked out of their own file
- Group
- Nothing
- Others
- Read, write, execute. Every unrelated account has full control
In detail
007 inverts the usual arrangement completely. The account that owns the file cannot read it, the group cannot read it, and every other account on the machine can read it, rewrite it and run it. It combines the maximum exposure of 777 with the practical uselessness of 000 for the person who is supposed to be using the file.
It nearly always comes from a transposition. 700 is the private directory mode, and typing the digits in the wrong order produces this. Because the person who made the mistake immediately cannot read the file, the error is usually discovered within seconds, which is the only merciful thing about it.
The way out is worth understanding. The owner runs chmod and it works, despite having no permission bits at all, because the authority to change a mode comes from ownership rather than from the mode. The same is true of chown restrictions and of deletion: an owner who cannot read a file can still change its mode, and anyone with write permission on the parent directory can still delete it.
While it is set, the exposure is complete. Any account, including a service account that some unrelated compromised process is running under, can modify the contents. If the file is a script that something privileged runs later, that is a straightforward escalation path, and the owner cannot even inspect the file to notice.
There is no legitimate use. Unlike 070, which at least demonstrates the class matching rule, 007 has no teaching value beyond showing that the owner is never locked out of chmod. Fix it to whatever was intended, which is 700 in the overwhelming majority of cases.
Examples
chmod 007 mistake.txt
chmod u=,g=,o=rwx mistake.txt$ ls -l secret.txt
-------rwx 1 alice alice secret.txt
$ cat secret.txt
cat: secret.txt: Permission denied
$ chmod 600 secret.txt # works, alice owns it
$ cat secret.txt
... contents ...chmod 700 ~/.ssh -> drwx------
chmod 007 ~/.ssh -> d------rwx
One transposed pair of digits, and the directory is open to
every account on the machine and closed to you.Things that catch people out
- The owner cannot read the file but can still change its mode, so the fix is one command and does not need root. People often reach for sudo unnecessarily here.
- 007 on a directory means the owner cannot list or enter it, while any other account can create and delete entries inside it freely.
- A file at 007 that is executed by a scheduled job is fully controlled by every unprivileged account on the machine. Treat any occurrence as an incident, not a typo to quietly correct.
- Because the owner notices immediately, the risky version of this mistake is the one made by a script on a file nobody opens for weeks.
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 070: Group Only Access and the First Match Rule
070 grants the group everything and the owner nothing. The owner really is denied, because the kernel checks one class only, and this mode proves it.
chmod 000: No Permissions for Anyone, and What Still Works
000 removes every permission from every class. What still works afterwards: root reads it, the owner can chmod it back, and it can still be deleted.
chmod 700: Private Directories Such as ~/.ssh
700 gives the owner read, write and execute and everyone else nothing. Why SSH insists on it for ~/.ssh and what breaks when a parent is more open.
chmod 4755: The setuid Bit and What It Actually Does
4755 sets the setuid bit on top of 755, so the program runs as its owner instead of as the caller. Where it is required and why it is dangerous.
chmod 2775: The setgid Bit on Directories and on Files
2775 adds the setgid bit to 775 so new files inherit the directory's group. The fix for shared directories where the team cannot edit each other's files.
chmod 1777: The Sticky Bit and Why /tmp Needs It
1777 adds the sticky bit to a world writable directory so only a file's owner can delete it. The mode of /tmp and the fix for any shared drop directory.
Tools for this
- Chmod Calculator Free online chmod calculator - calculate Unix file permissions with an interactive chmod builder