The octal digits are a straight sum: read = 4, write = 2, execute = 1, one digit each for owner, group, and others. chmod 755 file is rwxr-xr-x; chmod 644 file is rw-r--r--. A fourth leading digit carries the special bits (SUID = 4, SGID = 2, sticky = 1), which is why ls -l sometimes shows an s or a t where you expected an x. Three classes is the whole model: one owner, one group, everyone else. When a second user needs their own permission on a file that model cannot express it, and an ACL is what adds a per-user entry on top.
Table of Contents
A calculator you can run
Paste this into a bash shell. It converts an octal mode to its symbolic form, for example o2s 644 prints rw-r--r--, and needs no website. In zsh, the macOS default shell, the same function prints wrong strings (644 gives rwrr), so type bash first and then paste it:
o2s() { # octal -> symbolic
local m=$1 out= i c s
[ ${#m} -eq 4 ] || m=0$m
for i in 1 2 3; do
c=${m:$i:1}
out=$out$([ $((c & 4)) -ne 0 ] && echo r || echo -)
out=$out$([ $((c & 2)) -ne 0 ] && echo w || echo -)
out=$out$([ $((c & 1)) -ne 0 ] && echo x || echo -)
done
s=${m:0:1}
[ $((s & 4)) -ne 0 ] && out=${out:0:2}$([ "${out:2:1}" = x ] && echo s || echo S)${out:3}
[ $((s & 2)) -ne 0 ] && out=${out:0:5}$([ "${out:5:1}" = x ] && echo s || echo S)${out:6}
[ $((s & 1)) -ne 0 ] && out=${out:0:8}$([ "${out:8:1}" = x ] && echo t || echo T)${out:9}
printf '%s\n' "$out"
}
$ for m in 755 644 000 4755 4644 2755 1777 7777 6755 421; do printf '%-5s %s\n' $m "$(o2s $m)"; done
755 rwxr-xr-x
644 rw-r--r--
000 ---------
4755 rwsr-xr-x
4644 rwSr--r--
2755 rwxr-sr-x
1777 rwxrwxrwt
7777 rwsrwsrwt
6755 rwsr-sr-x
421 r---w---x
Those aren’t hand-typed. Every one of them was checked by running chmod on a real file and comparing against stat. Twenty-one modes round-tripped octal → filesystem → symbolic → octal with no mismatch; the check is in a script that changes permissions only on files it creates in its own temporary directory and needs no sudo.
Reading the special bits
The s/S and t/T distinction is the part nobody explains. Lowercase means the special bit is set and the execute bit under it is also set. Uppercase means the special bit is set and the execute bit is not — usually a mistake:
$ chmod 4755 s; stat -f '%Sp' s -> -rwsr-xr-x SUID, owner can execute
$ chmod 4644 s; stat -f '%Sp' s -> -rwSr--r-- SUID set on a non-executable file
$ chmod 2755 s; stat -f '%Sp' s -> -rwxr-sr-x SGID
$ chmod 1755 s; stat -f '%Sp' s -> -rwxr-xr-t sticky
$ chmod 7666 s; stat -f '%Sp' s -> -rwSrwSrwT all three, no execute anywhere
On a directory, SGID means new files inherit the directory’s group, and sticky means only a file’s owner may delete it — which is exactly what /tmp uses:
$ stat -f '%Sp %N' /tmp/ /var/tmp
drwxrwxrwt /tmp/
drwxrwxrwt /var/tmp
(The trailing slash matters on macOS, where /tmp is a symlink to /private/tmp and stat without it reports the link’s own lrwxr-xr-x. On Linux /tmp is a real directory and either form works.)
One behaviour worth knowing before you rely on SUID: writing to the file clears it.
$ chmod 4755 s; stat -f '%Sp' s
-rwsr-xr-x
$ echo data >> s; stat -f '%Sp' s
-rwxr-xr-x
And symbolic modes do not clear special bits you didn’t mention: after chmod +t s then chmod u=rw,go=r s, the file was still -rw-r--r--T. Use a four-digit octal mode when you want the special bits gone.
umask decides what new files get
chmod sets permissions on something that exists. umask subtracts permissions from things being created. The requested mode is 666 for a regular file and 777 for a directory, and the umask bits are removed from it:
umask 022 -> file 644 (-rw-r--r--) dir 755 (drwxr-xr-x)
umask 002 -> file 664 (-rw-rw-r--) dir 775 (drwxrwxr-x)
umask 077 -> file 600 (-rw-------) dir 700 (drwx------)
umask 000 -> file 666 (-rw-rw-rw-) dir 777 (drwxrwxrwx)
Note the last line: even with umask 000 a new file is 666, not 777. A umask can only take permissions away, and nothing ever asks for execute on a plain file. That is also why a freshly written script isn’t runnable until you chmod +x it.
x on a directory means traverse, not run
This is the single most common source of “permission denied on a file I can clearly see”:
$ chmod 755 dt; ls dt; cat dt/inside.txt
inside.txt
secret
$ chmod 644 dt # r, no x — you can list names but reach nothing
$ ls dt
ls: fts_read: Permission denied
inside.txt
$ cat dt/inside.txt
cat: dt/inside.txt: Permission denied
$ chmod 111 dt # x, no r — you cannot list, but you CAN open a known name
$ ls dt
ls: dt: Permission denied
$ cat dt/inside.txt
secret
Read on a directory lets you enumerate names. Execute lets you use a name to reach what’s behind it. They are independent, which is why chmod 711 on a home directory is a real pattern: others can traverse to a published path but cannot list what else is there.
Write on a directory is the same kind of trap. It controls creating and deleting entries, not the contents of the files:
$ rm -f writable_dir/read_only_file # file is 444, dir is 755
$ echo $?
0 # deleted anyway
$ rm -f readonly_dir/writable_file # file is 666, dir is 555
rm: readonly_dir/writable_file: Permission denied
About chmod 777
chmod 777 gives every account on the machine permission to modify the file. It is not recommended for most files, for security reasons — if it’s a script, a config file, or anything another process executes or trusts, any local user or compromised service account can rewrite it and the next run does what they wrote. When 777 “fixes” a problem, the actual problem is almost always ownership or a missing x on a parent directory; chown or chmod 755 on the directory path is the fix. The genuinely dangerous combination is a world-writable file that also carries SUID — chmod 4777 renders as -rwsrwxrwx, which is a root shell for anyone who can write to it.
Not tested here
All commands ran as a single unprivileged user on macOS 26.6; there was no second user account to demonstrate cross-user denial, so the “any local user can rewrite it” consequence of 777 is stated from the permission model rather than measured. SGID group inheritance on a directory was not measured either — setting SGID requires membership in the target group, and in /tmp on this machine new files inherit group wheel, so chmod 2755 there returned Operation not permitted. Everything else above is output from the commands shown.