[an error occurred while processing this directive] CGI - A free tutorial for the Total Non-Programmer.
CGI - Let's get startedCGI - Introduction to Perl

The chmod command

When you create your CGI programs, you will need to change the access privileges to that they can be executed from a web page.  To do this, you will use the chmod command.  The chmod command has 2 properties, who will have privileges, and which privileges will they have.

1. Who will have privileges?
There are 3 categories of who can have privileges, the User, the Group, and Others.

They are represented by the letters u, g, and o.  Also the letter 'a' can represent All the categories together.

2. What privileges can people have?
There are also 3 types of privileges: Read, Write, and eXecute, represented by the letters r, w, and x.

Privileges are assigned with an equals sign (=r, or =rw, or =rx), or added with a plus sign (+r, or  +rwx),  or subtracted with a minus (-w, or -rwx)

3. How do I type the command? For most CGI programs, I want to give read and execute privileges to the world, but not write, so that no one can delete or edit my program.  This is the most common command:

chmod a+rx filename.cgi

This means add the ability to read and execute to everyone.  When I first create a file, I have full read, write, execute privileges, but no one else has anything.  This command gives the world the ability to run my program.



SHORTCUT: You can also type a single digit number for user,group,others.
Add these values for each usertype:
   Read=4
   Write=2
   Execute=1
To allow yourself all privilages, and everyone else can read and execute (most common)
   chmod 755 filename.type
To allow everyone all privilages use: 777
To allow yourself to read and write, and other can only read: 644

Try this example.  You are still in the myfolder folder.

  1. Type ls -l and press [ENTER].

  2. A lot of information is displayed about practice.txt, including its size, its owner, and date last saved.
  3. Observe the access privileges, they may read rwx------ or perhaps rw-r--r-- or rw-r-----

  4. The first 3 places indicate the user privileges (read,write,execute).  The second three are the group privileges (none) and the third three are the other privileges (none).
    usr|grp|oth
     
  5. Type chmod a+rx practice.txt and press [ENTER].

  6. To add read and execute privileges to all categories:owner, group, and other.
  7. Type ls -l and press [ENTER].

  8. This time the privileges should read rwxr-xr-x , indicating that the owner still has full privileges, and that group and others have read and execute, but not write.
  9. Type chmod go-x practice.txt and press [ENTER].
  10. Type ls -l and press [ENTER].

  11. The privileges now read rwxr--r-- , indicating that the owner still has full privileges, and that group and others have only read privileges.

Remove the myfolder folder

  1. Type rm practice.txt and press [ENTER]
  2. Type cd ..
  3. Type rmdir myfolder

Try this matching game

 

1. Add Execute to Group users

a) chmod g=rw filename.txt

2. Remove Write from everyone

b) chmod o-r filename.txt

3. Everyone has only Read and Execute

c) chmod a+rx filename.txt

4. Add Read and Execute to everyone

d) chmod g+x filename.txt

5. Remove Write from others and group

e) chmod a-w filename.txt

6. Remove Execute from user

f) chmod a+r filename.txt

7. Group has only Read and Write.

g) chmod go-w filename.txt

8. Add Read to everyone

h) chmod a=rx filename.

txt

9. Remove read from others

i) chmod u-x filename.txt

 

Here is the answer key:
1 - d
2 - e
3 - h
4 - c
5 - g
6 - i
7 - a
8 - f
9 - b
 


 
BACKThe chmod | Locating Perl Program | emacs editor

Home | WebData - Web Database Software | Javascript | CGI | Consulting | Map Builder | Contact Us | The Press Room