The Power User's Shortcut
Instead of letters, you can use numbers to set all nine permission bits at once. This is called "octal mode" or "numeric mode." It's faster when you know exactly what final permission state you want.
Each permission has a numeric value:
- Read (
r): 4 - Write (
w): 2 - Execute (
x): 1 - No Permission (
-): 0
To calculate the permissions for a category (User, Group, or Others), you add up the values of the permissions you want:
rwx= 4 + 2 + 1 = 7 (Full permissions)rw-= 4 + 2 + 0 = 6 (Read and Write)r-x= 4 + 0 + 1 = 5 (Read and Execute)r--= 4 + 0 + 0 = 4 (Read only)-wx= 0 + 2 + 1 = 3 (Write and Execute, rare)-w-= 0 + 2 + 0 = 2 (Write only, very rare)--x= 0 + 0 + 1 = 1 (Execute only)---= 0 + 0 + 0 = 0 (No permissions)
You combine three of these numbers to set the full permission string: one digit for User, one for Group, one for Others.
Common permission patterns:
| Octal | Result | Meaning | Typical use |
|---|---|---|---|
755 |
rwxr-xr-x |
Owner full access; group/others read and execute | Executable scripts and binaries |
644 |
rw-r--r-- |
Owner read/write; group/others read-only | Configuration files and documents |
600 |
rw------- |
Owner only, no other access | Private keys and credentials |
700 |
rwx------ |
Owner only, full access | Private directories |
664 |
rw-rw-r-- |
Owner and group read/write; others read-only | Shared project files |
775 |
rwxrwxr-x |
Owner and group full access; others read/execute | Shared directories |
Why octal mode exists:
Octal mode is faster when you know the exact permission state you want. Instead of multiple symbolic commands (chmod u=rwx,g=rx,o=rx), you just type chmod 755. It's also unambiguous—there's no question about what the final state will be.
In infrastructure-as-code (Ansible, Terraform, Dockerfiles), you'll almost always see octal mode because it's explicit and deterministic.
Key Point: In production, octal mode is preferred for idempotency. A configuration management tool running
chmod 644 /etc/app/config.yamlwill always result in the same permission state, regardless of what the permissions were before. Symbolic mode likechmod g+wdepends on the current state, which can lead to drift over time if the file is manipulated by multiple processes. When writing Ansible tasks or Terraformlocal_fileresources, always specify permissions in octal.