← All cheatsheets

Shell

File permissions — chmod, chown, octal modes

## Read modes
`ls -l` — full permissions
`stat file` — detailed metadata

## chmod symbolic
`chmod u+x file` — add exec for user
`chmod g-w file` — remove write for group
`chmod o-r file` — remove read for other
`chmod a+r file` — add read for all

## chmod octal
Read = 4, Write = 2, Exec = 1. Sum for each role (owner, group, other).

`chmod 755 file` — rwxr-xr-x (typical for scripts)
`chmod 644 file` — rw-r--r-- (typical for text files)
`chmod 600 file` — rw------- (private secrets)
`chmod 700 dir` — rwx for owner only

## Ownership
`chown user:group file` — change owner + group
`chown -R user:group dir` — recursive