Language
English English Vietnamese (Tiếng Việt) Vietnamese (Tiếng Việt) Chinese (简体中文) Chinese (简体中文) Portuguese (Brazil) (Português do Brasil) Portuguese (Brazil) (Português do Brasil) Spanish (Español) Spanish (Español) Indonesian (Bahasa Indonesia) Indonesian (Bahasa Indonesia)

Write a permission string as nine bits and get the three-digit mode back, with the setuid group, umask notes and the rwx table on the same page.

Permission Bits and the Number chmod Wants

A Unix file mode is nine switches: read, write and execute, repeated for the owner, the group and everyone else. Documentation draws them as rwxr-xr-x, the kernel stores them as bits, and chmod takes them as a three-digit number. When you have worked out the switches and need the number, this page does the middle step for you.

Three bits per digit: group the string in threes from the right and each group becomes one octal digit. 111101101 becomes 111 101 101 = 755, the mode of a typical executable script.

Where Nine Bits Turn Up

Teaching the Permission Model

Course material introduces the switches first and the numeric mode second, so students spend a while translating between the two forms.

Hardening a Deployment

You decide which switch must come off a config file or a private key, then need the mode to write into the playbook or Dockerfile.

The same three-bit grouping explains why octal survives at all: base-8 was designed for machines whose words divided neatly into groups of three, and file permissions inherited the habit.

Grouping Your Bits in Threes

1

Write the switches as bits

Turn each letter into a 1 and each dash into a 0, left to right, owner first. rw-r--r-- becomes 110100100.

2

Take the three digits below

Nine bits always produce a three-digit mode. If you see only two digits, the owner group started with a zero and you can add it back yourself.

3

Use it on the command line

The copy button on the octal field adds the 0o marker used by Python and modern JavaScript. Strip it when you type a plain chmod 644 file.

The other direction: put a mode such as 640 into the lower field and its nine bits appear above, ready to read off as letters. Swap moves you to the octal-first page with the value carried across.

From rwx Bits to a chmod Number

Each three-bit group is independent, so you only ever need to know eight combinations. Learn this table and you can read any mode string at a glance, in either direction.

SwitchesBitsDigitWhat the holder may do
rwx1117Read, change and run it
rw-1106Read and change, but not execute
r-x1015Read and run, no edits — the usual script setting
r--1004Read only
-wx0113Write and run without reading — a rare drop box
--x0011Enter a directory without listing it

Digits Spaced in Threes

Longer octal results are shown in groups of three, which keeps a twelve-bit mode with its special-bit digit readable.

Letters Never Reach the Field

Typing r, w or x by mistake changes nothing — the input keeps only 0 and 1, so a half-translated string cannot be converted by accident.

Bookmark a Worked Example

A ?v= value in the address opens the page already filled in, which is useful for a runbook that documents one exact mode.

Permission Bit Questions

What if my bit count is not a multiple of three?

Grouping starts at the right, so the leftmost group is simply short — the value is still correct. For permission work, type all nine positions including the zeros so the digit count matches what chmod expects.

Where do setuid and the sticky bit fit in?

They live in a fourth group in front of the other nine. Type twelve bits instead: 100111101101 gives 4755, a setuid executable. The values are 4 for setuid, 2 for setgid and 1 for the sticky bit.

Why does a directory need the execute bit?

On a directory that bit means "may traverse". Without it you cannot reach anything inside, even with the read bit set, which is why 755 rather than 644 is the normal directory mode.

Can I convert a umask this way?

Yes, but remember a umask lists the bits to remove. Convert its nine bits as usual and read the answer as a subtraction: 000010010 gives 022, which strips group and other write access.

Does the result work as an argument in Ansible or Terraform?

Both want the digits quoted, as in mode: "0644", because an unquoted number would be read as decimal by the YAML parser. Paste the digits and add the leading zero and the quotes yourself.

01
0b
01234567
0o

rwx Groups as Digits

111 = 7
110 = 6
101 = 5
100 = 4
011 = 3
001 = 1

Binary (Base-2)

One position per permission switch: nine of them for owner, group and others, twelve when the special bits count.

Octal (Base-8)

The compact form chmod, umask and deployment tooling read, one digit standing for a whole rwx group.

Type all nine positions so the mode keeps three digits
111101101 groups as 111 101 101 = 755
Twelve bits add the setuid, setgid and sticky digit in front
The copy button adds 0o, which chmod does not want
Want to learn more? Read documentation →
1/5
Start typing to search...
Searching...
No results found
Try searching with different keywords