Octal to Binary
Convert octal numbers to binary, three bits at a time.
You run chmod 755 on a script and it starts working. Type chmod 644 on a file instead and something different happens. Those digits are octal, and the reason octal survives in one very specific corner of computing is that each digit maps onto exactly three binary switches.
Why permissions settled on octal
A Unix file has three permission flags — read, write and execute — and each one is a single binary switch, on or off. Three binary switches have exactly eight possible combinations, which is exactly what one octal digit can represent, 0 through 7.
That is not a coincidence; it is the whole reason chmod uses octal. One digit, three bits, three permissions. A hex digit would cover four bits and waste one; a decimal digit would not map onto bits at all.
What each octal digit switches on
| Octal digit | Binary | Permissions |
|---|---|---|
| 0 | 000 | no read, no write, no execute |
| 1 | 001 | execute only |
| 2 | 010 | write only |
| 4 | 100 | read only |
| 5 | 101 | read and execute |
| 6 | 110 | read and write |
| 7 | 111 | read, write and execute |
Reading chmod 755 and 644 as binary
chmod 755 has three digits, one per group of people: owner, group, everyone else. 7 is 111 in binary — the owner gets read, write and execute. Each 5 is 101 — group and everyone else get read and execute, but not write.
chmod 644 breaks down as 6, 4, 4. Digit 6 is (4 + 2) = 110 in binary, read and write for the owner. Each 4 is 100, read-only for group and everyone else. That single digit-to-three-bits mapping is the entire logic behind every permission number you will ever type.
Converting any octal number to binary
- Take each octal digit on its own, working left to right.
- Convert that digit to exactly three binary digits, padding with leading zeros where needed — 2 becomes 010, not 10.
- Write the three-bit groups next to each other in the original order.
- The result is the full binary number, with no digits dropped or merged between groups.
Octal to binary questions
Why is each octal digit always exactly three bits?
Because three bits can represent eight distinct values, 0 through 7, which is the entire range of a single octal digit. That one-to-one match is what makes the conversion mechanical rather than requiring long division.
What does chmod 777 mean in binary?
Each digit 7 is binary 111, so 777 grants read, write and execute to the owner, the group and everyone else. It is the most permissive setting and is rarely appropriate outside temporary testing.
Why not just use binary directly for permissions?
Nine raw bits are harder to read and type correctly than three octal digits. Octal keeps the same information in a shorter, less error-prone form, which is exactly why the convention stuck.
Does a four-digit octal permission number mean something different?
Yes. A leading fourth digit before the standard three sets special flags such as setuid, setgid and the sticky bit, each of which is itself controlled by one more bit beyond ordinary read, write and execute.
Can this converter handle octal numbers unrelated to permissions?
Yes. The conversion is the same regardless of what the octal number represents — permissions are simply the most common reason anyone needs it today.