Linux chmod permissions explained
A guide tells you to set 644 or run chmod 755, and it is worth knowing what the digits mean before you type them. Each digit is the sum of up to three permissions, and the three digits apply to the owner, the group and everyone else, in that order.
How to work out a chmod number
Read counts as 4, write as 2 and execute as 1. Calculate read, write and execute separately for the owner, the group and others, and add them up within each position: 6 is 4+2, 5 is 4+1 and 7 is 4+2+1. Verify with the reverse operation by splitting every digit back into its permissions. The digits are octal and independent of each other, so do not read 755 as an ordinary decimal number.
What 644 and 755 mean
For regular files, 644 means read and write for the owner and read only for the group and others. 755 additionally grants execute to all three and is common for executable scripts and for directories, since a directory needs execute permission before anyone can enter it.
Why 777 is not a fix
Avoid 777 as a generic answer to a permission error. It grants write permission far more broadly than most applications need, to every user on the system. Find out which user the program runs as and give that user the access it lacks. You can verify any mode with the 2ip chmod calculator.