What the digits mean
chmod changes POSIX file mode bits. A numeric mode like 777 is three octal digits for owner, group, and others. Each digit sums read (4), write (2), and execute (1). Seven therefore means rwx for that class. chmod 777 path expands to rwxrwxrwx: every local user class on the machine can read, modify, and execute the file (if it is a file) or traverse and create entries inside (if it is a directory).
Why tutorials say 777—and why ops teams hate it
Quickstarts use 777 to silence permission errors without thought. On servers, world-writable directories let any local user drop malware or steal secrets. World-writable files let anyone tamper with binaries or configs. Even “temporary” 777 often ships to production and becomes an audit finding.
Safer defaults
| Mode | Meaning | Typical use |
|---|---|---|
755 | rwxr-xr-x | Programs and web roots readable by all, writable only by owner |
750 | rwxr-x--- | Shared team dirs with no other access |
640 | rw-r----- | Config files group-readable, not world-readable |
600 | rw------- | SSH keys and secrets |
Directories vs files
Execute on a directory means traverse (cd into) and access listed names—often paired with read to enumerate entries. chmod -R is dangerous: verify tree scope before recursive changes.
Beyond chmod
umask subtracts bits from new files—pair sane defaults with correct ownership (chown) and groups. When POSIX modes are not enough, use ACLs (setfacl) for fine-grained sharing without opening the world.
Related: Linux chmod explained, Linux user and permission commands, What sudo does, Linux security commands.