It’s actually not a good idea to leave your permissions at 777 for ANY file/folder . . . .
The chmod command allows you to set certain permissions for files on your Web server. For instance, many scripts are set with the permissions for the owner to be able to read, write, and execute the file— while the permissions for the group and other (anybody) are set to allow them only read and execute permissions. The number that you use for this is 755
Another common permission, though it can be a security risk (anyone can write to the file), allows everyone in every grouping to read, write, and execute the file. The number for this is 777.
These numbers do mean something: The first number sets the permissions for the owner, the second sets the permissions for the group, and the last number sets the permissions for anyone else (other). Look at the chart below to see what each number means:
0 (zero)
No Permissions
(the user(s) cannot do anything)
1
Execute Only
(the user(s) can only execute the file)
2
Write Only
(the user(s) can only write to the file)
3
Write and Execute Permissions
4
Read Only
5
Read and Execute Permissions
6
Read and Write Permissions
7
Read, Write and Execute Permissions
So, placing 7 in all three positions means that everyone in every group can read, write and execute the file.
As another example, if you use chmod 650, here is the breakdown:
The first number, 6, gives the owner read and write permissions.
The second number, 5, gives the group read and execute permissions.
The last number, 0, gives all others no permissions for the file.
Hopefully that will make file permissions a little less troublesome for you. Now you will know how to set certain file permissions without guessing at random, although that eventually works too!