chmod Numeric Mode

You've seen permissions like 755 and 644. Let's understand where those numbers come from.

The Number System

Each permission has a value:

  • r (read) = 4
  • w (write) = 2
  • x (execute) = 1

Add them up for each user class:

rwx = 4+2+1 = 7
rw- = 4+2+0 = 6
r-x = 4+0+1 = 5
r-- = 4+0+0 = 4

Building Permission Numbers

Three digits: owner, group, others.

755 = rwxr-xr-x
│││
││└── Others: 5 = r-x
│└─── Group:  5 = r-x
└──── Owner:  7 = rwx

Common Permission Numbers

NumberSymbolicUse Case
644-rw-r--r--Regular files
755-rwxr-xr-xExecutables, directories
600-rw-------Private files (SSH keys)
700-rwx------Private directories
666-rw-rw-rw-Rarely used
777-rwxrwxrwxAvoid - too open
Terminal
$chmod 644 document.txt
$chmod 755 script.sh
$chmod 700 ~/.ssh
$chmod 600 ~/.ssh/id_rsa

Numeric vs Symbolic

Same result, different syntax:

NumericSymbolic
chmod 755 filechmod u=rwx,go=rx file
chmod 644 filechmod u=rw,go=r file
chmod 600 filechmod u=rw,go= file

Numeric is shorter. Symbolic is more readable.

When to Use Which

  • Numeric: When you know exactly what you want (755, 644)
  • Symbolic: When you're adding/removing specific permissions (u+x, g-w)

Memorize These

Most of the time, you only need these:

NumberMemory Aid
755Standard directories, executables
644Standard files
600Private sensitive files
700Private directories

The Calculation

Let's work through chmod 754:

7 = 4+2+1 = rwx (owner)
5 = 4+0+1 = r-x (group)
4 = 4+0+0 = r-- (others)

Result: rwxr-xr--

Going the other way:

rw-r--r-- = ?

Owner:  rw- = 4+2+0 = 6
Group:  r-- = 4+0+0 = 4
Others: r-- = 4+0+0 = 4

Result: 644

Real-World Usage

Web Files

Terminal
$chmod 644 index.html style.css
$chmod 755 uploads/

SSH Keys

Terminal
$chmod 600 ~/.ssh/id_rsa
$chmod 644 ~/.ssh/id_rsa.pub
$chmod 700 ~/.ssh/

SSH is picky about permissions. Too open = won't work.

Scripts

Terminal
$chmod 755 deploy.sh
Knowledge Check

What permission number gives owner full access and everyone else read-only?

Quick Reference

PermissionNumber
---0
--x1
-w-2
-wx3
r--4
r-x5
rw-6
rwx7

Key Takeaways

  • r=4, w=2, x=1 - add them for each class
  • Three digits: owner-group-others
  • 755 for executables/directories
  • 644 for regular files
  • 600/700 for private files/directories
  • Numeric is faster, symbolic is clearer

Next: changing file ownership with chown and chgrp.