UNIX Commands

To understand the chmod command, you must first understand the concept of file/directory access permissions.
Access permissions
A file/directory can have 3 kinds of permissions

File r read/view the contents
w write/edit the contents
x execute/run the file

Directory r search the contents of the directory
w change the contents of the directory
x make it the present working directory

And there are 3 types of Users: user, group, others u the user who owns the file or directory
g members of this group owns the file or directory
o the rest of the world

The access permissions for these 3 types of users are then expressed with a string of 9 characters user
group others rwx rwx rwx

If a file called foo.exe has permissions shown below...
-rwxr-x--x 1 joe admin 245 Jan 3 15:10 foo.exe
then the user joe can read, edit and run the file...
whoever is in the group admin can read, run, but not edit the file...
the others (rest of the world) can only run the file. They cannot read or edit it.

The chmod command
Permissions can be expressed in numbers. r 4
w 2
x 1

Therefore... rwx 7 (which is 4+2+1)
rw- 6 (which is 4+2)
r-x 5 (4+1)
and so forth.

For example, the file bar.cgi has the following permissions...
-rw------- 1 joe joe 245 Jan 3 15:10 bar.cgi
... issuing the command...
chmod 750 bar.cgi
... will result in the file having the following permissions....
-rwxr-x--- 1 joe joe 245 Jan 3 15:10 bar.cgi

The syntax for the chmod command is...
chmod mode filename
chmod mode directoryname
where mode refers to the permssions settings (i.e. the 3 numbers).