Chmod
From JumbaWiki
- The title of this article should be chmod. The initial letter is capitalized due to technical restrictions.
chmod is a Unix command for setting the permissions of a file (from change mode). This command is used to tell the server who can do what with the files located there, and it can be run from most FTP programs.
Who can
There are three "whos" that a Unix server is concerned with:
The owner of the file The group that owns the file Everyone else
Every file and every directory has an owner. On your web site, the owner of all of the files is probably you, but it can also be a generic user called 'nobody'. If you aren't the owner and don't belong to the group that owns the file you are just a user. Someone browsing your web site falls into this category.
Do what
There are three things you can do with a file:
Read it Write it Execute it
Reading a file means you can look at it. In the case of a visitor to your website, it usually means that they can see it in their browser. Having write permissions on a file means that you can edit it, make changes to it, even erase it. Execute permissions mean that the file can be run on the server (the file is executed by the server). When using a script written in Perl or PHP, the script file usually must have execute permissions or the server will not run them (servers using phpSuExec are an exception).
Settings
File permissions are represented as a 3-digit number.
- The first digit represents permissions of the owner
- the second is permissions for the Group, and
- the third the permissions for everyone else ("world").
Each digit is the sum of permissions, where
- Read = 4
- Write = 2
- Execute = 1
So if a digit is 7, this means all permissions: read + write + execute (4 + 2 + 1)
If a digit is 5, this means there are read and execute permissions only (4 + 1)
Some examples follow:
777: everyone can read/write/exec
owner permissions = 7 = read + write + execute group permissions = 7 = read + write + execute world permissions = 7 = read + write + execute
755: owner can do all, others can read/exec
owner permissions = 7 = read + write + execute group permissions = 5 = read + execute world permissions = 5 = read + execute
644: owner can read/write, others can read only
owner permissions = 6 = read + write group permissions = 4 = read world permissions = 4 = read

