permissions

chmod

Changes file mode (permission bits). Accepts symbolic modes like u+x or octal modes like 755.

chmod [OPTION]... MODE[,MODE]... FILE...

Common flags

Flag Purpose
-R Recurse into directories
-v Verbose -- describe every action
-c Report only files whose mode actually changes
--reference Use the mode of the given reference file

Examples

chmod 755 script.sh

rwxr-xr-x -- owner writes, everyone reads and runs

chmod +x deploy.sh

Add execute permission for user, group, and others

chmod -R go-w /var/www

Recursively remove write for group and others

chmod u=rw,go= secret.key

Owner read/write, no access for anyone else

Gotcha

chmod -R on a mixed tree gives execute bits to files too; use find with -type d/-type f to apply directory and file modes separately.

Related commands

← All Linux commands · Linux cheat sheet