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 it 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.
Example
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.
Notes
- For a directory, execute means “may traverse into it”; without it you can’t open files even if you can list names.
- write on a directory lets you create and delete entries — including files you don’t own — unless the sticky bit restricts deletion to owners.
- setuid is ignored on shell scripts on most modern kernels for security; it only affects binaries.
- Default modes come from your
umask, which subtracts bits from the base666(files) or777(directories).