chmod
Permissions
Usage
chmod 755 [path]Sets the permission bits on files and directories; chmod -R 755 makes plain files executable too, so use the capital X form to leave files alone.
Common flags
| Flag | Meaning |
|---|---|
| 0755 | Numeric: owner, group, others, each read 4 + write 2 + execute 1 |
| u+w | Symbolic: who (u g o a), then + - =, then r w x |
| +x | Add the execute bit, the usual fix for a script |
| -R | Apply to a whole tree |
| +X | Execute for directories only, never for plain files |
| -v | Name each file whose mode changed |
| -h | BSD and macOS: change the symlink itself, not its target |
Examples
chmod +x deploy.shMakes the script runnable.
chmod -R u+rwX,go+rX,go-w site/Capital X keeps files non-executable.
chmod 600 ~/.ssh/id_ed25519What ssh insists on for a private key.
Numeric and symbolic modes name the same thing: 755 and u=rwx,go=rx are the same permission.
How to read this
- Square brackets [ ] mark a part you may leave out.
- An ellipsis … means you can list more than one.
- Flags are case-sensitive — in some commands -r and -R do different things.
Questions
Q. What does chmod do?
Sets the permission bits on files and directories; chmod -R 755 makes plain files executable too, so use the capital X form to leave files alone.
Q. How do I type it?
chmod 755 [path] — square brackets mark the parts you can leave out.
Q. How many flags are worth knowing?
7 are listed here; the full set is in man chmod. This command sits under Permissions.
Related commands
man page: man chmod