The Devs Tools

Developer's Guide to Chmod Calculator: Best Practices and Examples

August 18, 2026 · The Devs Tools Team

Every file and directory on a Unix-like system (Linux, macOS, BSD) carries a permission set that controls who can read, write, or execute it. These permissions are split across three actor classes — owner, group, and others — and three action bits per class: read (r), write (w), and execute (x). The chmod command is how you change these bits, and it accepts two notations: symbolic (u+x, go-w) and octal (755, 644). Octal notation compresses each three-bit permission triplet into a single digit from 0-7, calculated by summing read (4), write (2), and execute (1) for whichever permissions are granted. A directory with rwxr-xr-x becomes 755: the owner gets 4+2+1=7, while group and others get 4+0+1=5. Getting this arithmetic wrong is a common source of either broken deployments (permissions too restrictive, so a web server can't read a file) or serious security holes (permissions too permissive, so any local user can write to it). Execute bits also mean something different on directories than on regular files — on a directory, x controls whether you can cd into it or traverse it at all, not whether you can "run" it. Understanding this distinction is essential before running chmod -R recursively across a tree, since blindly applying the same octal value to files and directories alike often breaks directory traversal or leaves files executable when they shouldn't be.

[!TIP] Need to work out an octal permission value now? Try our free, local Chmod Calculator to toggle read, write, and execute bits and get the octal code and full command instantly, completely offline.


Reading a Permission String

A full ls -l permission string has 10 characters, e.g. -rwxr-xr-x. The first character indicates the file type (- for a regular file, d for a directory, l for a symlink), followed by three groups of three:

-  rwx  r-x  r-x
^   ^    ^    ^
|  owner group others
type

Each group maps directly to an octal digit:

Permission Binary Octal
rwx 111 7
rw- 110 6
r-x 101 5
r-- 100 4
-wx 011 3
--x 001 1
--- 000 0

Common Octal Values and When to Use Them

  • 644 (rw-r--r--): The standard for regular files like HTML, CSS, config files, and images. Owner can edit, everyone else can only read.
  • 755 (rwxr-xr-x): Standard for directories and executable scripts. Anyone can traverse the directory or run the script, but only the owner can modify it.
  • 600 (rw-------): For sensitive files like SSH private keys or .env secrets — owner-only access, no group or public read.
  • 777 (rwxrwxrwx): Full access for everyone. Almost never the right answer in production; it's a common misconfiguration that lets any user on a shared system read, modify, or execute a file.

A Practical Workflow

# Make a deploy script executable by the owner only
chmod 700 deploy.sh

# Standard web asset permissions
chmod 644 index.html style.css

# Recursively fix a directory tree: dirs need x to be traversable, files don't
find /var/www/app -type d -exec chmod 755 {} \;
find /var/www/app -type f -exec chmod 644 {} \;

# Symbolic form: add execute for the owner without touching other bits
chmod u+x run.sh

Note the last find pattern — it's the safe way to apply different permissions to directories versus files in one tree, since a single chmod -R 755 would make every file executable too.


Conclusion

Chmod arithmetic is simple once the read/write/execute-to-4/2/1 mapping clicks, but it's easy to mistype a digit under pressure during a deploy or SSH session. Working through the permission matrix visually, rather than doing the octal math in your head, removes that risk — especially when you're setting permissions on something security-sensitive like a key file or a shared server directory.