chmod 500: Owner Only Read and Execute, Nothing Else
500 is r-x------: the owner can read and execute, cannot write, and no other account has any access. It is a private program or a frozen private directory, protected against a careless edit rather than against an attacker.
At a glance
- Octal
- 500, written 0500 in four digit form
- Symbolic
- u=rx,g=,o=
- On a file
- -r-x------
- On a directory
- dr-x------
- Owner
- Read and execute. Cannot write, so cannot save over it or add entries
- Group
- Nothing
- Others
- Nothing
In detail
500 is 700 with the write bit taken away. On a file that means the owner can run it and read it but an editor will refuse to save, which is exactly what you want on a personal script that has bitten you once by being edited by accident, or on a program you keep in ~/bin and would rather not modify without thinking about it.
On a directory it produces something more interesting: the owner can list the names and traverse in, and cannot create, rename or delete anything. The set of entries is frozen while the files themselves remain editable according to their own modes. That is a neat way to protect the shape of a directory without protecting every file in it.
As with 555, this is a guard rail and not a control. The owner can run chmod u+w at any moment, because the ability to change a mode comes from owning the file rather than from having write permission on it. Against yourself it works well; against anything adversarial it works not at all.
The private half is what distinguishes it from 555. Nothing outside the owning account can read, run or traverse, so a 500 script keeps its contents private in a way a 555 one does not. For a personal automation script that embeds a path or a hostname you would rather not publish to every account on a shared machine, this is the right shape.
Watch the interaction with backups and syncing. Tools that recreate a directory tree will happily fail partway through when they cannot write into a 500 directory, and some report the failure only in a summary line. If you freeze a directory, make sure whatever writes into it is expected to fail, not merely likely to.
Examples
chmod 500 ~/bin/backup.sh
chmod u=rx,g=,o= ~/bin/backup.shdr-x------ 2 alice alice /home/alice/archive/
$ ls /home/alice/archive # works, read bit is set
$ cd /home/alice/archive # works, execute bit is set
$ touch newfile
touch: cannot touch 'newfile': Permission denied
$ rm oldfile
rm: cannot remove 'oldfile': Permission deniedchmod u+w ~/bin/backup.sh
$EDITOR ~/bin/backup.sh
chmod 500 ~/bin/backup.shThings that catch people out
- 500 does not stop the owner from changing the file, only from changing it without noticing. One chmod undoes it.
- Backup, sync and package tools that write into a 500 directory fail partway through, and the error is often buried in a summary rather than raised as the first failure.
- A 500 script is readable and executable only by its owner, so a scheduled job running as a different account cannot run it at all, even one belonging to the same person's group.
- Removing write from a directory does not protect the files inside. Their contents follow their own modes; only the list of names is frozen.
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 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 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 550: Programs a Service Can Run but Cannot Change
550 gives the owner and group read and execute and everyone else nothing. The mode for a privileged script that a service must run but must not modify.
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.
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 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.
Tools for this
- Chmod Calculator Free online chmod calculator - calculate Unix file permissions with an interactive chmod builder