Here's an easy method to determine which numbers to use for the "chmod"
command, when you want certain permissions for certain people.
Remember chmod uses 3 numbers, using anything else could result in trouble.
Convert each of those numbers out to binary. (Remember the scale is 0-7)
Affix read/write/execute to each.
chmod# | read write execute
-------+------------------------
0 | 0 0 0 (no reading, writing or executing)
1 | 0 0 1
2 | 0 1 0 0 (zero) means NO
3 | 0 1 1
4 | 1 0 0 1 (one) means YES
5 | 1 0 1
6 | 1 1 0
7 | 1 1 1 (allows read, write, and execute)
--------------------------------
chmod 711 is used for directories and chmod 644 is used for files
now catch this: (ie. chmod 711 public_html)
User Group Outsiders (see note below)
----------------------------
7 1 1 Used for directories only!
6 4 4 Used for files only!
7 5 5 Can read the files in this directory.
Definitions:
------------
User: The USER is you, and only you.
Every directory you own should have read, write and execute set to yes.
Group: Everyone else who has the same group name as you (usually "users")
Other: Everyone else, that isnt you or in your Group
(This example comes from using the command: ls -l)
total 41
-rw-r--r-- 1 sbirl users 5129 Aug 11 11:44 UNIX_help.html
-rw-r--r-- 1 sbirl users 2092 Sep 10 10:03 about_chmod
-rw-r--r-- 1 sbirl users 7879 Jun 27 10:53 example.html
-rw-r--r-- 1 sbirl users 3130 Sep 9 12:25 index.html
-rw-r--r-- 1 sbirl users 2667 Jul 1 12:04 setting_web_pages_101
-rw-r--r-- 1 sbirl users 2861 May 15 12:07 tricks.html
-rw-r--r-- 1 sbirl users 3981 Jul 1 12:30 using_lynx.html
-rw-r--r-- 1 sbirl users 2609 Feb 13 1997 web_programming_101
-rw-r--r-- 1 sbirl users 6411 Feb 13 1997 web_programming_201
***^^^###
Notice that the first name is sbirl. This is the OWNER of the file.
The *** represents what the OWNER is allowed to do to that file.
Notice that the second name is users. This is the GROUP of the file.
The ^^^ represents what other people of the same GROUP is allowed to do to
that file.
Since Group is users, anyone from the same group is allowed to read that file.
If, for the file index.html, the permissons read:
-rw-rw-r-- 1 sbirl users 3130 Sep 9 12:25 index.html
( As opposed to:
-rw-r--r-- 1 sbirl users 3130 Sep 9 12:25 index.html )
Then anyone in the users group could write anything into this particular
file and save it. But we dont usually want that to happen.
Note:
-----
When it comes to directories, the EXECUTE permission (for the OTHER group)
must be set in order for outsiders to access any file(s) within that
directory. Simply giving a directory READ permissions, will *not* do anything.
People must be able to "enter" into the directory, which is what the
EXECUTE permission does. How can you view documents if you cant enter
into the directory?
Although you may give a directory EXECUTE, no one will know what files
are in that directory without the READ permission (unless of course you
tell them about a file, or they are lucky guessers.)
If there are certain files you don't want anyone to know about, then
don't give the READ permissions to OTHERS for the directory and/or the file.