Converting...
File Permission Breakdown
| Scope | Octal | Bits | Read (4) | Write (2) | Exec (1) | Notation |
|---|---|---|---|---|---|---|
| Owner | 7 | 111 | ✓ | ✓ | ✓ | rwx |
| Group | 5 | 101 | ✓ | — | ✓ | r-x |
| Other | 5 | 101 | ✓ | — | ✓ | r-x |
chmod 755 <file> Add a 0o prefix in source code — e.g. os.Chmod(path, 0o755)Place-value breakdown · 3 digits (base 8)
| Position | Digit | Power | Place Value | Contribution |
|---|---|---|---|---|
| 2 | 7 | 8^2 | 64 | 7 × 64 = 448 |
| 1 | 5 | 8^1 | 8 | 5 × 8 = 40 |
| 0 | 5 | 8^0 | 1 | 5 × 1 = 5 |
What Is the Octal Number System?
The octal number system is a base-8 positional numeral system that uses eight digits: 0, 1, 2, 3, 4, 5, 6, and 7. Each digit position represents a successive power of eight, exactly as decimal uses powers of ten. The value of an octal number is the sum of each digit multiplied by its positional power.
Octal gained prominence with the PDP minicomputers of the 1960s and early 1970s, where 18-bit and 36-bit word sizes divided neatly into six or twelve 3-bit groups. Unix inherited this legacy and still uses octal to represent the nine permission bits of a file mode: three bits for the owner, three for the group, and three for everyone else. When you type chmod 755 script.sh, those three digits are octal.
In programming languages, an octal literal is written with a leading zero in C and older Go code (0755) or with the explicit 0o prefix in modern Go and Python (0o755). Forgetting the prefix is a common source of permission bugs: os.Chmod(path, 755) passes the decimal number 755 instead of the octal value, resulting in completely wrong permissions.
Quick example
745 (octal) = 7×8² + 4×8¹ + 5×8⁰ = 7×64 + 4×8 + 5×1 = 448 + 32 + 5 = 485 (decimal)
How to Convert Octal to Decimal
Multiply each octal digit by 8 raised to the power of its position, counting positions from right to left starting at zero. Add all the products together.
Worked example: convert 755 (octal) to decimal.
| Digit | Position | Power | Place Value | Contribution |
|---|---|---|---|---|
| 7 | 2 | 8² | 64 | 7 × 64 = 448 |
| 5 | 1 | 8¹ | 8 | 5 × 8 = 40 |
| 5 | 0 | 8⁰ | 1 | 5 × 1 = 5 |
| Total | 493 | |||
So 755 (octal) = 493 (decimal). To convert in the opposite direction — decimal to octal — divide the decimal number repeatedly by 8, recording each remainder. Reading the remainders from bottom to top gives the octal result. For example: 493 ÷ 8 = 61 remainder 5 → 61 ÷ 8 = 7 remainder 5 → 7 ÷ 8 = 0 remainder 7. Reading upward: 755.
How to Convert Octal to Binary
Octal and binary have an especially clean relationship: each octal digit maps to exactly three binary bits. This is because 8 = 2³, so one octal digit spans exactly one 3-bit group. You can convert any octal number to binary digit by digit without any arithmetic.
The eight possible octal digits and their 3-bit binary equivalents:
| Octal | Binary | Octal | Binary |
|---|---|---|---|
| 0 | 000 | 4 | 100 |
| 1 | 001 | 5 | 101 |
| 2 | 010 | 6 | 110 |
| 3 | 011 | 7 | 111 |
To convert 755 (octal) to binary, substitute each digit: 7 → 111, 5 → 101, 5 → 101. Concatenate the triplets: 111 101 101. This visual grouping explains why octal is the natural representation for Unix permissions — each triplet maps directly to one set of rwx bits.
To convert binary back to octal, group the binary digits into triplets from right to left (pad with leading zeros if needed), then replace each triplet with its octal digit.
How to Convert Octal to Hex
There is no direct one-to-one digit mapping between octal and hexadecimal because 8 and 16 are not powers of each other. The reliable two-step method is to convert through binary: octal → binary → hex.
Converting 755 (octal) to hex
Step 1: 755 (oct) → 111 101 101 (bin)
Step 2: group in 4-bit nibbles from the right: 0001 1110 1101
Step 3: 0001 = 1, 1110 = E, 1101 = D → 0x1ED
Alternatively you can convert octal to decimal first and then from decimal to hex, though the binary route is usually faster for mental arithmetic.
The hex digit F (15 decimal) requires four bits (1111), which is why two hex digits always represent exactly one byte, while three octal digits represent only 9 bits — not a full byte boundary. This mismatch is one reason hex has largely replaced octal in modern computing contexts like color codes and memory addresses.
Linux File Permissions Explained (chmod Octal)
Every file and directory on a Unix or Linux system has a 9-bit permission mask stored as three groups of three bits. The first triplet controls what the file owner can do, the second controls the owning group, and the third controls all other users. Each triplet encodes read, write, and execute rights: read = 4, write = 2, execute = 1. Add the values of the permissions you want to get the digit for each group.
| Mode | Symbolic | Meaning |
|---|---|---|
| 755 | -rwxr-xr-x | Owner can read, write, execute. Group and others can read and execute only. Standard for web scripts and executables. |
| 644 | -rw-r--r-- | Owner can read and write. Group and others can read only. Standard for regular files and HTML. |
| 600 | -rw------- | Owner can read and write only. No access for others. Use for SSH private keys and sensitive config files. |
| 777 | -rwxrwxrwx | All permissions for all users. Never use on a web server — any user can overwrite or execute the file. |
| 444 | -r--r--r-- | Read-only for all users. Write and execute denied. Good for published assets that must not be modified. |
| 700 | -rwx------ | Owner has full access. No access for group or others. Use for personal scripts and directories. |
| 664 | -rw-rw-r-- | Owner and group can read and write. Others read only. Common for shared team files on multi-user systems. |
Special permission bits — setuid (4), setgid (2), and sticky (1) — add a fourth leading octal digit. For example, 4755 makes an executable run as its owner regardless of who launches it (setuid). This tool covers the standard 3-digit octal modes. For 4-digit modes refer to man chmod.
Octal Reference Table (0–17)
The table below covers the first 16 values in octal (0 through 17 octal = 0 through 15 decimal). These are the values within a single hex digit, making this a useful cross-reference for base conversions.
| Octal | Decimal | Binary | Hex |
|---|---|---|---|
| 0 | 0 | 000 | 0 |
| 1 | 1 | 001 | 1 |
| 2 | 2 | 010 | 2 |
| 3 | 3 | 011 | 3 |
| 4 | 4 | 100 | 4 |
| 5 | 5 | 101 | 5 |
| 6 | 6 | 110 | 6 |
| 7 | 7 | 111 | 7 |
| 10 | 8 | 1000 | 8 |
| 11 | 9 | 1001 | 9 |
| 12 | 10 | 1010 | A |
| 13 | 11 | 1011 | B |
| 14 | 12 | 1100 | C |
| 15 | 13 | 1101 | D |
| 16 | 14 | 1110 | E |
| 17 | 15 | 1111 | F |
Frequently Asked Questions
What is 0755 in octal?
In C and older Go code, a leading 0 marks an integer literal as octal. So 0755 in source code IS the octal number 755, which equals 493 in decimal. The confusion arises when developers forget the prefix: os.Chmod(path, 755) passes the decimal number 755 (octal 1363), not the intended permission mode. Modern Go and Python use 0o755 to make the intent unambiguous.
How do you convert octal to decimal?
Multiply each octal digit by 8 raised to its positional power and sum the results. For a three-digit octal number ABC: result = A×64 + B×8 + C×1. For 755: 7×64 + 5×8 + 5×1 = 448 + 40 + 5 = 493.
What does chmod 755 mean?
The three digits represent permissions for the owner, group, and others respectively. 7 (111 in binary) grants read, write, and execute. 5 (101 in binary) grants read and execute only. So chmod 755 gives the owner full access and gives group and others read plus execute access — the standard permission for an executable script or web application directory.
Why do Linux permissions use octal?
Each permission set (owner, group, other) consists of exactly three bits: read, write, execute. Three bits can represent values 0–7, which fits perfectly in one octal digit. One three-digit octal number can therefore encode all nine permission bits in a compact, human-readable form.
Is chmod 777 safe?
No, 777 means any user on the system can read, write, and execute the file. On a shared web server this allows anyone — including malicious scripts running under a different user — to overwrite or replace your files. Use 755 for executables and directories, 644 for regular files, and 600 or 700 for files that must remain private.
How do you convert octal to binary?
Replace each octal digit with its 3-bit binary equivalent. 0→000, 1→001, 2→010, 3→011, 4→100, 5→101, 6→110, 7→111. For 755: 7→111, 5→101, 5→101 giving 111101101. No arithmetic is required — it is a direct digit substitution.
What is the largest 3-digit octal number?
777 octal, which equals 511 in decimal and 111111111 in binary (nine 1-bits). This represents the maximum value encodable in 9 bits and corresponds to full rwxrwxrwx permissions in Linux.
What is the difference between octal and hex?
Both are shorthand representations of binary data, but they group bits differently. Octal groups bits in threes (one octal digit = 3 bits), while hexadecimal groups bits in fours (one hex digit = 4 bits = one nibble, two hex digits = one byte). Hex aligns neatly with 8-bit bytes and 64-bit addresses, which is why it dominates modern computing. Octal aligns neatly with 3-bit permission groups, which is why Unix still uses it for file modes.