Octal to decimal: decoding a mode, a mask or an old dump
What this conversion does
It reads a base 8 value and restates it in base 10. This is the direction you need when a mode is already written in octal — as chmod and ls expect — and the number has to go into a script, a configuration field or a comparison where decimal is what the surrounding code assumes.
Each position is a power of eight
From the right, the weights are 1, 8, 64, 512 and so on. Convert 755 and you get 7 × 64 + 5 × 8 + 5 = 493. Note that the digits are not three independent permissions any more once the value is decimal — the packed structure that made the octal form readable is exactly what a decimal conversion dissolves, which is worth remembering before you use the result.
Octal to decimal conversion table
Octal modes and masks with their decimal values. Converting a permission mode to decimal is useful for scripting; keeping it in octal is better for reading, so most teams record both.
| Octal | Decimal |
|---|---|
| 0 | 0 |
| 1 | 1 |
| 7 | 7 |
| 10 | 8 |
| 17 | 15 |
| 100 | 64 |
| 377 | 255 |
| 644 | 420 |
| 755 | 493 |
| 1000 | 512 |
Why octal use narrowed to permissions
A base earns its place by matching the machine's grouping. Octal fitted the six-bit and twelve-bit words of early hardware, and as soon as eight-bit bytes became universal the natural grouping became four bits, and therefore hexadecimal. Permissions survived because they are genuinely nine bits wide and split evenly into three groups of three — a case where the arithmetic of the base still matches the structure of the data.
Do not do permission maths in decimal
Adding a decimal 493 and 64 to grant read access looks reasonable and is not: 64 is decimal sixty-four, and the bit it sets in an octal mode is not the read bit you wanted. Do permission arithmetic in octal, using values like 400 and 40, and convert only for storage or display.
Frequently asked questions
How do I convert octal to decimal by hand?
Multiply each digit by its place value — 1, 8, 64, 512 and so on from the right — and add the results. For 755 that is 7 × 64 + 5 × 8 + 5, which is 448 + 40 + 5, or 493.
Why does chmod 755 show as 493 in my script?
Because the script is reading the mode as a plain decimal integer. The file system stores the same bits either way; only the notation differs. Keep the octal form in your head and comments, and convert at the boundary where the value meets code that expects decimal.
What is the largest octal value I can convert here?
Far larger than any practical mode or mask. The conversion runs in exact integer arithmetic, so long inputs come back with every digit correct instead of the rounded result a floating-point calculator would produce.
Is a leading zero significant in octal?
Not numerically — 0755 and 755 are the same value — but it is a useful marker that says "this is octal", and several languages require it for an octal literal. The converter accepts a leading zero and any 0o prefix on input, and never prints one on output.
Does the tool accept fractions in octal?
Yes, and it reports honestly when one cannot be represented. Some octal fractions terminate and some do not, depending on whether the denominator is a power of two. When the expansion does not terminate the result is truncated and clearly marked, rather than rounded as though the answer were exact.