Here's a brief overview of the three numbers in a permission "code":
-The first number is for the owner of the file. If you set a file at 600, the owner will have read and write access and everyone else is locked out.
-The second number is for the users group (users are placed into groups to get special rights sometimes). Generally you will not give write access to a user's group.
-The third number is for the rest of the world, including web users. Setting any value that will allow write access to the world is not smart (aka 666 and 777).
Explanation of the permission values:
-To get a permission value, you add up certain amounts, depending on what permissions you want:
-- 4 is equal to read access
-- 2 is equal to write access
-- 1 is equal to execute access (or, in the case of a directory's permissions, it equals directory listing access, meaning you can retrieve a listing of all the files in a directory).
Let's look at this in a real-world example:
We have Joe's web site. He has the web page file home.html, the directory scripts, and the script file contact.php, which is located in scripts:
/
/home.html
/scripts/
/scripts/contact.php
We should set the permisions for each file as follows, for the reason outlined:
-home.html: 644 - this will give the file write access to the owner, and read access to the rest of the world.
-/scripts/: 755 - this will allow the owner all rights (read, write, listing), and give outsiders everything but write access.
-/scripts/contact.php: 755 - this will give the owner full rights, as well as allow the script to execute under any user.
This is not an exhaustive guide to *nux file permissions, and don't take me for a Linux system admin. But it will help the average hosting user understand how to give permissions to his site's files.
Edit: Please note that if you include a file in a PHP script using the include(), include_once(), or the require equivelants, then you don't need to CHMOD the file that you're including.


