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
chown
Changes the owner and/or group of files and directories. Requires appropriate privileges (usually root) to reassign ownership.
ls
Lists directory contents including files and subdirectories. Supports detailed views, sorting, and filtering to inspect the filesystem quickly.
find
Recursively walks directories evaluating expressions on each entry. Combines discovery with actions like exec or delete.