Back

File permissions (chmod)

Every file has permissions for read (r), write (w), and execute (x), set separately for the owner, the group, and everyone else. chmod changes them. Numbers add up: read = 4, write = 2, execute = 1. So 7 = rwx, 6 = rw-, 4 = r--.

ls -l
# -rw-r--r--  1 daniel staff  script.sh
#  owner group others

chmod +x script.sh     # make it executable
./script.sh

chmod 755 script.sh    # rwx r-x r-x
chmod 644 notes.txt    # rw- r-- r--
chmod 600 ~/.ssh/id_ed25519  # private key: only you

Roadmap