How the numbers work
Each permission digit is just addition: read = 4, write = 2, execute = 1. Owner, group and others each get one digit, so 755 means the owner can do everything (4+2+1) while group and others can read and execute (4+1). Tick boxes above and watch the octal and the ls -l-style symbolic string update together, after a few minutes the mapping sticks permanently.
The modes you'll actually type
644 for ordinary files (owner writes, world reads), 755 for directories and executables, 600 for anything containing secrets: SSH keys, .pgpass, API credential files. OpenSSH enforces this one: it will refuse a private key that is group- or world-readable. 664/775 appear on group-collaborative directories, and 777 appears in Stack Overflow answers, treat it as a red flag, not a fix. If 777 "solves" a permission problem, the real problem was ownership, and chown was the answer.
Files vs. directories
Execute means something different on a directory: it grants the right to enter it and reach the inodes inside. A directory with r-- but no x lets you list names but not open any of them, which produces genuinely confusing errors. This is why directories are 755 where files are 644, and why chmod -R 644 on a tree breaks it, use find /path -type d -exec chmod 755 {} + and -type f -exec chmod 644 {} + instead.
The fourth digit
A leading digit adds special bits: setuid (4) runs an executable as its owner (how passwd edits root-owned files), setgid (2) on a directory makes new files inherit the directory's group (the standard trick for shared project folders) and the sticky bit (1) on a world-writable directory means only a file's owner can delete it, which is exactly the 1777 mode of /tmp.