Number Systems

Octal Converter

Convert between octal, decimal, binary, and hex in your browser. Includes Unix chmod permission mapping and a plain-language guide to Base-8.

Unix chmod Mapping
Aviation Squawk Reference
Runs Locally โ€” No Server
What Is Octal?

Base-8 in plain terms

Octal is a number system that counts in groups of eight using the digits 0 through 7. Each octal digit represents exactly three binary bits โ€” which is why it became the natural shorthand for early computers whose word sizes were multiples of three (12-bit, 24-bit, 36-bit systems).

Today, hexadecimal dominates memory addresses and color codes because modern hardware uses 8-bit bytes (which map cleanly to two hex digits). But octal never disappeared. It's baked into Unix file permissions, aviation transponders, and several programming language standards โ€” and understanding it is still a practical skill for anyone working close to the operating system.

Decimal 8

10โ‚ˆ

Octal has no '8' digit โ€” it wraps like decimal wraps at 10

Decimal 64

100โ‚ˆ

Powers of 8: 8ยน=8, 8ยฒ=64, 8ยณ=512

Decimal 255

377โ‚ˆ

The maximum value of one byte in octal

Unix File Permissions

Why chmod uses octal

Unix permissions describe what three groups of users โ€” the file's owner, the owner's group, and everyone else โ€” are allowed to do with a file. Each group gets three flags: Read (r), Write (w), and Execute (x). Three flags, three bits โ€” and three binary bits map to exactly one octal digit (0 through 7).

This is why chmod 755 makes sense as a command rather than something verbose like "owner rwx, group r-x, others r-x". One digit per group, and you're done.

Octal permission reference

OctalBinarySymbolicMeaning
7111rwxRead, write, execute
6110rw-Read and write only
5101r-xRead and execute only
4100r--Read only
3011-wxWrite and execute
2010-w-Write only
1001--xExecute only
0000---No permissions

Commonly used chmod values

755

Public web server files & directories

Owner writes; everyone reads and executes

644

Static config files, HTML, CSS

Owner writes; everyone reads

700

Private scripts, SSH keys

Owner has full access; no one else

777

Avoid in production

Everyone can do everything โ€” a security risk

600

Private key files (e.g. ~/.ssh/id_rsa)

Owner reads and writes; completely locked to others

1755

/tmp directories, shared folders

755 plus sticky bit: others can't delete files they don't own

4755

Privileged executables (e.g. sudo, passwd)

Runs with owner's privileges regardless of who executes it

Special Permission Bits

SUID, SGID, and the sticky bit

A standard chmod value uses three digits. A fourth leading digit activates special-purpose flags that aren't part of the basic read/write/execute model.

4xxx

SUID (Set User ID)

When set on an executable, the file runs with the privileges of the file's owner rather than the user who launched it. The classic example is /usr/bin/passwd โ€” regular users need elevated privileges to update the password database, but only for that specific program.

chmod 4755 /usr/bin/passwd
2xxx

SGID (Set Group ID)

On a file, it works like SUID but for the group. On a directory, any file created inside inherits the directory's group rather than the creating user's primary group โ€” useful for shared project directories where team members need consistent group ownership.

chmod 2775 /var/www/shared
1xxx

Sticky Bit

On a directory, users can create and edit their own files but cannot delete files owned by others, even if the directory is world-writable. /tmp is the canonical example โ€” everyone can write to it, but you can't clean up someone else's temp files.

chmod 1777 /tmp
Aviation

Why aircraft transponders speak octal

Every commercial and private aircraft in controlled airspace broadcasts a four-digit transponder code โ€” called a squawk code โ€” assigned by air traffic control. If you've ever looked at a flight tracking app and noticed the codes only contain digits 0 through 7, that's octal at work.

When the original ATC transponder system was designed in the 1960s, the hardware used four rotary switches, each controlling three bits of data. Three bits per digit, four digits: 12 bits total, 4,096 possible codes (8โด). The international aviation community has kept the octal standard ever since โ€” not because it's elegant in 2026, but because every radar system, protocol, and piece of air traffic infrastructure worldwide is built around it.

Reserved squawk codes

7500Hijacking in progress
7600Radio communications failure
7700General emergency
1200VFR flight in US airspace (no ATC contact)
0000Default / unassigned
Conversion Reference

How to convert octal manually

Octal โ†’ Decimal

Multiply each digit by 8 raised to its positional power (right to left, starting at 0), then sum the results.

# Convert octal 752 to decimal

7 ร— 8ยฒ + 5 ร— 8ยน + 2 ร— 8โฐ

= 7 ร— 64 + 5 ร— 8 + 2 ร— 1

= 448 + 40 + 2

= 490

Decimal โ†’ Octal

Repeatedly divide by 8 and collect the remainders in reverse order.

# Convert decimal 490 to octal

490 รท 8 = 61 remainder 2

61 รท 8 = 7 remainder 5

7 รท 8 = 0 remainder 7

= 752 (read remainders bottom to top)

Binary โ†’ Octal

Group binary digits into sets of three from the right, then convert each group to its octal equivalent. No math required โ€” just a lookup.

# Convert binary 111101010 to octal

111 | 101 | 010

7 | 5 | 2 = 752

In Code

Octal literals in programming languages

Most languages support octal literals so you can write permission values directly without converting mentally. The syntax varies โ€” and one historical convention caused real, widespread bugs.

C / C++

int perms = 0755;

Leading zero signals octal. Caused famous bugs when developers padded decimal values with leading zeros โ€” e.g. 0644 is fine, but 0890 is a syntax error because 8 and 9 aren't valid octal digits.

Python 3

perms = 0o755 os.chmod('file.txt', 0o644)

Python 3 switched from the leading-zero convention to an explicit 0o prefix to eliminate ambiguity. Python 2 used the leading-zero style, which caused bugs during migration.

JavaScript / Node.js

fs.chmod('file.txt', 0o755, callback);

ES6 and later use 0o prefix. Older code used plain 0755, which still works but is deprecated in strict mode.

Bash / Shell

chmod 755 file.txt chmod u=rwx,go=rx file.txt

Shell chmod accepts raw octal directly (no prefix needed) or symbolic notation. Both produce identical results.

Tips

Practical notes for working with octal

โœฆ Never use 777 in production

World-writable, world-executable files are a serious security risk. If a web server processes a 777-permissioned script, any process on the machine can modify it. Use 755 for directories and 644 for files as a sane default.

โœฆ ls -l shows symbolic, stat shows octal

ls -l displays permissions as -rwxr-xr-x. To see the octal value directly, run stat -c '%a %n' filename on Linux, or stat -f '%OLp %N' on macOS.

โœฆ The leading-zero bug is still out there

JSON doesn't support octal literals, so 0755 in a JSON config is just decimal 755. Configuration parsers vary โ€” always verify whether your tooling treats leading zeros as octal or decimal.

โœฆ umask is octal subtraction

The umask command sets which permission bits are removed from new files. umask 022 removes write from group and others, resulting in 644 for files and 755 for directories created by default.

โœฆ Sticky bit is visible in ls -l

chmod 1777 /tmp shows as drwxrwxrwt โ€” the trailing 't' replaces the 'x' in the others column to indicate the sticky bit. A capital 'T' means sticky is set but execute is not.

โœฆ Octal in network configs

Some legacy network device configs and mainframe systems still express masks and flags as octal. If you encounter a number that only uses digits 0โ€“7 and seems oddly large for its purpose, check whether it's being interpreted as octal.

FAQ

Common questions

Why does Unix use octal for file permissions instead of hex?

Unix permissions consist of three bits per user class (Read, Write, Execute). Three binary bits map perfectly to a single octal digit (0โ€“7), so one digit per class is all you need. Hex maps to four bits, which leaves an awkward remainder when describing three-bit groups. Octal fits exactly.

What does chmod 755 actually mean?

The owner has read, write, and execute (7 = 4+2+1). Group members and all others have read and execute but not write (5 = 4+0+1). It's the standard for publicly accessible web server files and directories.

Why do aviation squawk codes only use 0โ€“7?

1960s transponder hardware allocated three bits per digit across a 12-bit system, naturally producing octal values. The system provides 4,096 unique codes (8โด). Modern aviation maintains the standard for global compatibility.

What are SUID, SGID, and sticky bits?

A fourth leading digit in a chmod value sets special flags. 4 (SUID) runs a file with the owner's privileges. 2 (SGID) uses the group's privileges, or on a directory, propagates group ownership to new files. 1 (sticky bit) on a directory prevents users from deleting files they don't own.

Is octal still used in modern programming?

Yes. System administration is the most common case. Most languages support octal literals โ€” C uses leading 0, Python and JavaScript use 0o prefix. The old leading-zero convention has caused real bugs when developers padded decimal numbers with zeros and got unintended octal interpretation.

๐Ÿ”’

Runs entirely in your browser. All conversions happen locally using JavaScript. No values you enter โ€” file paths, permission strings, squawk codes โ€” are sent to any server. You can verify this by checking the Network tab in your browser's DevTools while using the tool.

Feedback

Live