From rwxr-xr-x to 755, and why umask 033 is not 633
Permissions are easiest to read once you see them as twelve switches. The last nine are in three groups of three, for the owner, the group and everyone else, and each group is read, write and run in that order. ls -l prints a letter for each switch that is on and a dash for each that is off, so rwxr-xr-x says: owner has all three, group has read and run, others have read and run. That is the whole meaning; the number is a shorter way to write it.
To turn the letters into a number, give each switch in a group a value: read is 4, write is 2, run is 1. Then add up each group on its own. rwx is 4+2+1, which is 7. r-x is 4+0+1, which is 5. So rwxr-xr-x is 755. Going back is the same in reverse: 6 can only be 4+2, so a 6 is rw-, and 640 is rw-r-----, read and write for the owner, read for the group, nothing for anyone else. Each digit has exactly one way of being built from 4, 2 and 1, which is why octal is used here at all: one digit, one group.
The three special bits sit in front, as a fourth digit with the same 4, 2, 1 values: setuid, setgid and sticky. They have no letter of their own in ls, so they borrow the run slot. A set setuid bit turns the owner’s x into s, so 4755 prints as rwsr-xr-x. Setgid does the same in the group’s slot, and sticky shows as t in the others’ slot, so 1777, the mode of /tmp, prints as rwxrwxrwt. If the special bit is on but the run bit under it is off, ls uses a capital: 4644 prints as rwSr--r--. That capital is worth noticing, because a setuid file that cannot run is usually a mistake.
The umask is where the arithmetic catches people out. When a program creates a file it normally asks for 666, read and write for everyone, and for a folder 777. The umask then turns off the bits it names. With umask 022 the write bits for group and others go, and files come out 644 while folders come out 755. It is tempting to think of this as 666 minus 022, and here that happens to give the right answer. Try umask 033 instead. 666 minus 033 is 633, which would be rw--wx-wx, a strange mode that gives others write and run but not read. The real answer is 644. In bits, 666 is 110 110 110 and 033 is 000 011 011; the umask clears the bits it has set, and the run bits it names were never on in 666, so only the write bits go: 110 100 100, which is 644. The tool always works bit by bit, so it gets this right.
The command it gives comes in two forms. chmod 755 deploy.sh sets all twelve bits at once and is what most guides show. chmod u=rwx,g=rx,o=rx deploy.sh says the same thing in letters, which some people find easier to read in a script. Both replace every permission on the file; neither is a relative change such as chmod +x, which only adds a bit.
Some limits. This covers classic Unix permission bits. It does not show access control lists (the + at the end of some ls -l lines), SELinux labels or Windows permissions, all of which can allow or block access on top of these bits. And the umask section shows the defaults that programs get when they ask for 666 or 777; a program that asks for less, such as an SSH client writing a key as 600, gets less.