Click to return to home page
Richard Lowe Jr Home

Protection Codes

All files on an Apache server are given a protection code which determines who can access the file and what they can do with it. 

A protection code is a number with three digits, each from 0 to 7. The three digits indicate what can be done by the file owner, the group and everyone (the world).

Each digit is a bit mask of three bits. and each bit indicates what can be done by the respective group. For files the bit values are "read", "write" and "execute". Thus the owner digit indicates if the owner can execute, read or write the file.  For directories the bits indicate read, write and search.

The table below shows how the bits and digits relate.

  Owner Group Public
Read=4 1=yes, 0=no 1=yes, 0=no 1=yes, 0=no
Write=2 1=yes, 0=no 1=yes, 0=no 1=yes, 0=no
Execute=1 1=yes, 0=no 1=yes, 0=no 1=yes, 0=no

This a file with a protection code of "700" would indicate the owner can do anything he wants and nobody else can do anything. A protection code of "777" allows anything to do anything.

On a web site (only those running a Unix operating system), you typically set the protection code from your FTP program. In CuteFTP this is done by issuing the CHMOD selection from the "Commands" menu.

CuteFTP has made the process very easy by including check boxes for each possible value. Using this program you do not even need to know what the numbers mean!

Here are some typical settings:

  • 777 - Everyone can do anything
  • 755 - CGI script (some servers require 777)
  • 666 - Data file
  • 644 - Configuration file or other static document (including HTML)
  • 400 - Disable script

Additional Reading

  • CGI scripting CGI scripts are a way to get data to and from a server. Many paid hosts support it, and some of the free hosts are beginning to.
  • CGI- What the Heck Is That? What is CGI? It's a way to get a web server to do something for you.
  • CGI protection codes Adding CGI scripts to your web site? Be sure you understand how the protection scheme works before you do!
  • Drawbacks Of CGI CGI scripts are a universal and easy way to get a server to do something for you. However, there are some drawbacks.
  • Formmail Security Issues Formmail is a great CGI routine which is very common on the internet. It is used to allow data to be entered and emailed, and it has a basic security flaw.

Unless otherwise noted, all photos and text is Copyright © Richard G Lowe, Jr.