Changing Permissions — Numeric (Octal) Mode
Each permission has a numeric value: read = 4, write = 2, execute = 1. Add them together for each class.
| Value | Permissions |
| 7 | rwx (4+2+1) |
| 6 | rw- (4+2) |
| 5 | r-x (4+1) |
| 4 | r-- (4) |
| 0 | --- (none) |
# Owner: rwx, Group: r-x, Other: r-x — common for scripts/directories
chmod 755 deploy.sh
# Owner: rw-, Group: r--, Other: --- — common for private config files
chmod 640 secrets.conf
# Apply recursively to a directory and everything inside it
chmod -R 755 /var/www/html
Warning — -R Applies to Everything Underneath — A recursive chmod sets the same mode on files and directories alike, which is rarely what you actually want (directories typically need execute permission to be traversable, in a way individual files don't). Consider find with -type f / -type d for more precise recursive changes.