Who can do what.
THE THREE PERMISSIONS
Read, write, execute.
THE THREE GROUPS
The owner, the group, everyone else.
WHAT THE NUMBERS MEAN
Read is 4, write is 2, execute is 1. They add up.
644 means the owner can read and write; everyone else can read.
755 means the owner can do everything; everyone else can read and execute.
WHAT WEB FILES USUALLY NEED
Directories: 755
Files: 644
WHAT NEVER TO SET
777, which allows anyone to write.
That is the most commonly suggested fix on forums and it is almost always wrong and dangerous.
WHEN SOMETHING WILL NOT WRITE
The cause is usually ownership rather than permissions.
Check who owns the file before changing permissions.
FOR CONFIGURATION FILES CONTAINING CREDENTIALS
More restrictive, so only the owner can read them.
WHAT TO DO IF UNSURE
Ask before changing permissions broadly.