The Unix chmod Command

chmod is the Unix command for setting file permissions.
Permissions are granted for u (users), g (groups), and
o (others), or a (all, everyone).

Permissions allow you to have r (read) access, w (write) access,
or x (execute) access.

To set a file permission so that everyone can read it:
chmod a+r filename

To set a directory so that everyone can open it and read its contents:
chmod a+rx dirname

To set a file so that noone can read it:
chmod a-r filename

To set a file so that you can't write to it (write lock it):
chmod u-w filename

To view file permissions:
ls -l filename
 
To view directory permissions:
ls -ld directoryname

   The permissions field contains 10 characters.  The first character
identifies whether the entry is for a directory (d) or for a file (-).
The rest of the characters indicate the read, write, and execute
permissions for the owner, for the group with which the file is
associated, and for all users.

           permissions     permissions     permissions
           for owner       for group       for other users

       d    r  w  x         r  w  x        r  w  x
    or
       -    -  -  -         -  -  -        -  -  -

 
where r = read, w = write, x= execute permission, and - = no permission

For example:
   drwxrwx---    is a directory.  The owner and group members have read,
                 write, and execute permission.  Others have no
                 permission.
   -rwxr-xr--    is a file.  The owner has read, write and execute
                 permission.  Group members may read and execute the file.
                 Other users have read only permission.
  
Caution! Never make your directories or files writeable by others. If you do this you put your files and account at risk! Always check the permissions of files that you have uploaded using an ftp program. Some ftp programs may set the permissions in ways you might not expect!