Shell
File permissions — chmod, chown, octal modes
Linux file permissions: read ls -l modes, use chmod symbolic and octal forms, and change ownership with chown and chgrp.
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