Commands · Command

CommandLinuxmacOS

chmod

chmod [options] mode file

Changes a file or directory's permission bits — who can read, write, or execute it.

// FLAGS

-Rrecursive, apply to a directory and everything inside it
-vverbose, print each change made

// EXAMPLE

chmod 755 deploy.sh — gives the owner full read/write/execute, everyone else read/execute — a common setting for making a script runnable.

// GOTCHA

chmod 777 (everyone gets full access) is a common "quick fix" for a permissions error, but it's a real security risk on anything reachable by other users or the network — the actual fix is almost always ownership (chown) or a narrower mode.

// RELATED COMMANDS