Octal and Unix file permissions
Why chmod uses base-8 numbers, how each octal digit maps to read, write and execute bits, and how to read modes like 755 and 644 at a glance.
Why permissions are written in octal
A Unix file stores permissions as nine bits, split into three groups of three for the owner, the group and everyone else. Three bits happen to hold exactly one octal digit, from 0 to 7, which is why a mode fits neatly into three octal figures. That tidy mapping is the reason chmod and ls settled on base 8 rather than decimal or hex. Each digit summarises one group's read, write and execute rights in a single character.
Reading the three permission bits
Within each group the read bit is worth 4, the write bit is worth 2 and the execute bit is worth 1. You add up the bits that are set to get the octal digit, so read and write together make 6, while read, write and execute make 7. A digit of 5 means read and execute but not write, the classic setting for a program a user may run but not change. Because the values 4, 2 and 1 never overlap, every combination has one unique digit.
Decoding common modes
Mode 755 gives the owner full read, write and execute, and read plus execute to the group and others, which suits scripts and directories. Mode 644 grants the owner read and write while everyone else gets read only, the usual choice for ordinary files. Convert those octal modes back to decimal and you get 493 and 420, the numbers some tools and APIs store internally. Pasting either form into this converter lets you move between the two views quickly.
From decimal back to a mode
Sometimes a config file, log or programming language reports a permission as a plain decimal integer rather than the familiar three-digit octal. Converting it back to octal reveals the real mode: 511 becomes 777, wide-open access, and 448 becomes 700, private to the owner. Doing the conversion by hand means dividing by 8 twice and collecting remainders, but this tool does it instantly. That makes it easy to audit a permission that some system printed in an unexpected base.