Chmod 664 means:
- The owner of the file has read and write access
- The users who belong to the same group have read and write access
- Other users have read access
An overview of permissions:
- Execute
- Write
- Write + Execute
- Read
- Read + Execute
- Read + Write
- Read, Write, Execute
Normal files should never get execute permissions, so either use 2, 4 or 6. Unknown users shouldn't be able to write in your file, so, 4 is the only option left for them.
Folders need Execute permission, so that files can be written. It's recommended to set the permissions of a folder to 555.
The three numbers represent Owner, Group and All (as mentioned earlier).