chmod codes
Permissions and ownerships are the most common cause of errors when setting up services and sites. Here we cover permissions:
Usage:
chmod [permissions: owner - group - everyoneelse] file
chmod nnn file
Where n =
0 = --- = no access
1 = --x = execute
2 = -w- = write
3 = -wx = write / execute
4 = r-- = read
5 = r-x = read / execute
6 = rw- = read / write
7 = rwx = read / write / execute
so 777 is rwxrwxrwx - anyone can read, write to or execute the file (not good unless you really want anyone to be able to write to this file)
774 (rwxrwxr--) means the owner and group can read, write to and execute the file, but 'everyone else' can only read it.
from http://en.wikipedia.org :
Special Modes
There are three so called special modes as well: the sticky bit, set user ID, and set group ID.
* 1000: If the sticky bit, set by adding octal number 1000 to the permissions, is applied to a directory, then only the file owner, the directory owner, or superuser can delete a file in that directory. For example, if a directory has permissions 0770, then the directory owner or anyone in the directory's group can add files or delete any files (regardless of who the file's owner is). If the sticky bit is set, so the permissions are 1770, then anyone in the group can add files to the directory, but each user can only delete her own files.
* 4000: This permission sets the set user ID bit. When a directory has this permission, files created within the directory have the user ID of the directory, rather than that of the user who created the file. Note that some operating systems don't allow you to use this numerical value, instead forcing you to use the symbolic alternative.
* 2000: This octal permission code sets the set group ID bit. When a directory has this permission, files created within the directory have the group ID of the directory, rather than that of the default group setting for the user who created the file. Note that some operating systems don't allow you to use this numerical value, instead forcing you to use the symbolic alternative.