The 9 bits that decide everything
Every Unix file has three sets of three permission bits: read, write, execute — for owner, group, others. ls -l shows them as rwxr-xr--: owner has all three, group has read+execute, others only read.
Symbolic chmod
chmod u+x file— add execute for ownerchmod g-w file— remove write from groupchmod o= file— remove all permissions for otherschmod a+r file— read for all (a = u+g+o)
Numeric chmod
Each rwx is one octal digit. r=4, w=2, x=1. Add them: rwx=7, rw-=6, r-x=5, r--=4. Three digits = owner/group/others.
chmod 755 script.sh— rwxr-xr-x. Standard for executables.chmod 644 file.txt— rw-r--r--. Standard for regular files.chmod 600 ~/.ssh/id_ed25519— rw-------. Required for SSH private keys.chmod 700 ~/.ssh— rwx------. SSH dir.
Directories
On a directory, x means "can enter" (cd into), r means "can list contents," w means "can add/remove entries." That's why scripts often need chmod 755 on a dir, not 644.
chown — change owner
chown alice file changes owner to alice. chown alice:staff file sets owner and group. -R for recursive. Often requires sudo because you usually can't give your files away to other users.
umask — default permissions
When you create a file, the kernel uses 0666 & ~umask; for directories 0777 & ~umask. The default 022 umask gives 644 files and 755 dirs. umask 077 makes new files readable only by you — useful in dotfiles where private data lives.