What is Octal Notation?
In Linux file systems, octal notation is a base-8 numeric system used to represent file permissions concisely. Instead of typing string modes like rwxr-xr-x, administrators write a 3-digit or 4-digit number like 755.
The 4-2-1 Bit Value System
Each octal digit (from 0 to 7) is calculated by adding the numeric values of enabled permission bits:
4Read (r)Value of bit 2²
2Write (w)Value of bit 2¹
1Execute (x)Value of bit 2°
Octal Values (0 to 7) Table
| Octal Digit | Calculation | Binary Triplet | Symbolic | Permissions Granted |
|---|---|---|---|---|
0 | 0 + 0 + 0 | 000 | --- | None |
1 | 0 + 0 + 1 | 001 | --x | Execute only |
2 | 0 + 2 + 0 | 010 | -w- | Write only |
3 | 0 + 2 + 1 | 011 | -wx | Write & Execute |
4 | 4 + 0 + 0 | 100 | r-- | Read only |
5 | 4 + 0 + 1 | 101 | r-x | Read & Execute |
6 | 4 + 2 + 0 | 110 | rw- | Read & Write |
7 | 4 + 2 + 1 | 111 | rwx | Read, Write & Execute |
3-Digit vs 4-Digit Format
Standard octal uses 3 digits (e.g. 755). When special bits (Setuid, Setgid, Sticky Bit) are applied, a leading 4th digit is prefixed:
- 4000 (Setuid): Executes process with owner privileges.
- 2000 (Setgid): Executes with group privileges or inherits group directory ownership.
- 1000 (Sticky Bit): Restricts file deletion in public directories.
Example: 4755 sets Setuid (4) alongside Owner (7), Group (5), and Others (5).