Unix file permissions control who can read, write and execute each file. They are
encoded as three sets of rwx bits — for owner, group and other — plus three
special bits. This tool lets you build a mode visually, read off both the octal
chmod value and the ls -l string, and decode an octal mode in reverse.
How the octal system works
Each permission has an octal weight: read = 4, write = 2, execute = 1. Add them per class to get one digit:
rwx = 4+2+1 = 7
rw- = 4+2 = 6
r-x = 4+1 = 5
r-- = 4 = 4
Three digits give owner, group and other (e.g. 755). A leading fourth digit
holds the special bits: setuid = 4, setgid = 2, sticky = 1, so 4755
is a setuid executable.
In ls -l the same information appears as a 9-character string like rwxr-xr-x.
When a special bit is set it overrides the execute character: s/S for
setuid/setgid, t/T for sticky — uppercase when the underlying execute bit is
off.
Most common modes and when to use them
| Mode | ls -l | Typical use |
|---|---|---|
644 | rw-r--r-- | Regular data files, HTML, configs readable by all |
600 | rw------- | SSH private keys, secrets — owner only |
755 | rwxr-xr-x | Executables, directories open to all |
700 | rwx------ | Private directories, home dirs |
2775 | rwxrwsr-x | Shared group directory, new files inherit group |
1777 | rwxrwxrwt | Sticky-bit world-writable, like /tmp |
Example: shared upload directory
A shared upload directory that is group-writable and keeps files owned by their
creators uses 2775: owner and group get rwx, other gets r-x, and the setgid
bit makes new files inherit the directory’s group. Its ls -l string is
rwxrwsr-x.
mkdir /srv/uploads
chown root:webteam /srv/uploads
chmod 2775 /srv/uploads
Notes
- For a directory, execute means “may traverse into it”; without it you cannot
open files even if you can list names — a common trap with
644on directories. - Write on a directory lets you create and delete entries, including files you do not own, unless the sticky bit restricts deletion to the file’s owner.
setuidis ignored on shell scripts on most modern kernels for security; it only affects compiled binaries.- Default modes come from your
umask, which subtracts bits from the base666(files) or777(directories). Aumaskof022produces644for files and755for directories.
Quickly decoding an unknown mode
When you see a mode in ls -l like rwsr-xr-x and want to know the octal, read it left to right: owner rws = 4+2+1 = 7 with setuid, group r-x = 5, other r-x = 5, setuid prefix = 4. Full octal: 4755. Use the decode field in this tool to verify: type 4755 and confirm the symbolic string matches. This is useful when auditing scripts or configs that include mode strings that are not immediately obvious.