How do you use chmod to change file permissions?
Two styles: symbolic like chmod u+x file makes a RELATIVE tweak (add/remove one bit, leave the rest alone), while numeric like chmod 755 file sets ALL nine bits at once to an absolute value.
Pick by intent. Symbolic (u+x, g-w, o=r) is surgical — "add execute for the owner, touch nothing else" — ideal when you don't know or care about the current mode. Numeric is declarative — "the mode IS 755" — ideal when you want a known end state and don't mind overwriting whatever was there. The = operator in symbolic mode is the bridge: chmod u=rwx,g=rx,o= sets exact bits like numeric does.
Symbolic mode: chmod [who][operator][permission] file
| Who | Operator | Permission |
|---|---|---|
| u (user) | + (add) | r (read) |
| g (group) | - (remove) | w (write) |
| o (other) | = (set exactly) | x (execute) |
| a (all) |
Symbolic examples:
chmod u+x file # Add execute for owner
chmod g-w file # Remove write from group
chmod o=r file # Set other to read-only
chmod a+r file # Add read for everyone
chmod ug+rw file # Add read+write for user and group
Numeric mode: chmod ### file
Each digit = user, group, other (r=4, w=2, x=1)
# rwxr-xr-x
chmod 755 file
# rw-r--r--
chmod 644 file
# rw-------
chmod 600 file
# rwx------
chmod 700 dir
Common permissions:
| Octal | Symbolic | Use case |
|---|---|---|
| 755 | rwxr-xr-x | Executable scripts, directories |
| 644 | rw-r--r-- | Regular files |
| 600 | rw------- | Private files |
| 700 | rwx------ | Private directories |
Go deeper:
chmod(1) — symbolic and numeric modes — the
[ugoa][+-=][rwx]symbolic syntax vs absolute octal modes.