Tool · Unix permissions

chmod calculator

Octal and symbolic Unix permissions, in both directions. Click the bit grid to toggle; type in either field to drive the other. Includes setuid, setgid, and sticky.

Result

Drives both forms from the bit grid below. Click any cell to toggle.

octal (4 digits)
0644

Leading digit is the special-bits nibble. 0 is the normal case. Most chmod invocations write three digits; the fourth is for setuid (4), setgid (2), and sticky (1), summed.

symbolic (rwx, 9 chars)
rw-r--r--

User, group, other. Each is read, write, execute. When the special bits are set, x in the relevant position becomes s (setuid/setgid) or t (sticky); when the special bit is set but execute is not, it shows as uppercase: S, T.

ls -l preview
-rw-r--r--

First character is the entry kind. - for regular file, d for directory, l for symlink. Switch the kind with the row of buttons below.

chmod command
chmod 644 path/to/file

Drop into a shell. Pick a path or paste your own; the octal updates live.

who \ bit
read (4)
write (2)
execute (1)
user
r
w
x
group
r
w
x
other
r
w
x
special
setuid (4)
setgid (2)
sticky (1)

Reference

Bit values

BitOctalPositionEffect on fileEffect on directory
read4rOpen for readingList entries
write2wOpen for writingCreate, delete, rename entries
execute1xRun as a programEnter (traverse) the directory
setuid4 (×1000)u-slot s/SRun with file owner's UIDIgnored on Linux
setgid2 (×1000)g-slot s/SRun with file group's GIDNew entries inherit dir's GID
sticky1 (×1000)o-slot t/THistoric (ignored)Only owner can delete entries

Reading ls -l

The first character is the entry kind: - file, d directory, l symlink, c char device, b block device, p named pipe, s socket. Then nine permission characters in three groups of three: user, group, other.

When a special bit is on, the x in that group changes shape: lowercase if execute is also on, uppercase if execute is off. So rwsr-xr-x has setuid and user-execute. rwSr-xr-x has setuid but no user-execute (rare but legal; the program would not be runnable as the owner). drwxrwxrwt is the canonical /tmp: world-writable but sticky, so only the owner of an entry can delete it.

Common shapes

OctalSymbolicUse
644rw-r--r--Regular file. Owner reads and writes, world reads.
600rw-------Private key, secret file. Anything else and ssh refuses.
700rwx------Private home, private script. Only owner traverses.
755rwxr-xr-xExecutable or directory. World reads and traverses, owner writes.
775rwxrwxr-xGroup-writable directory. Common in shared project dirs.
1777rwxrwxrwt/tmp. World-writable, sticky: each entry deletable only by its owner.
4755rwsr-xr-xsetuid binary. Runs as the file's owner. Audit before adopting.
2775rwxrwsr-xsetgid directory. New entries inherit the directory's group.

Notes that bit me

References

By Truffle. Source at github.com/truffle-dev/tool-chmod. MIT. Sibling tools at /public/tools/.