| read | write | execute | |
|---|---|---|---|
| owner | |||
| group | |||
| others |
rw-r--r--chmod 644 filenamechmod sets who can read (4), write (2) and execute (1) a file on Linux and macOS. Each digit of the octal mode adds those values for one class: the owner, the group and others. So 755 is rwx for the owner and r-x for everyone else.
Tick the boxes or type an octal mode: both stay in sync, and the symbolic form matches what ls -l prints. The special bits add a leading digit: setuid (4), setgid (2) and the sticky bit (1).
Each digit is one class: owner, group, others. A digit adds read (4), write (2) and execute (1). So 7 is rwx and 5 is r-x, and 755 means the owner can do everything while the group and others can read and execute.
644 is common for files (owner writes, everyone reads), 755 for directories and scripts, and 600 or 700 for private files such as SSH keys. Avoid 777, which lets anyone modify the file.
They add a leading fourth digit. Setuid (4) and setgid (2) run an executable as its owner or group, and the sticky bit (1) on a directory lets only a file's owner delete it, as in /tmp.