Of all the different problems associated with installing CGI scripts, many
can be attributed to incorrect permission settings on one file or another.
Permissions are very important on a Unix system because it prevents unauthorized
people from viewing or editing files. Anyone using a Unix system has an identity,
and file and directory access depends on "who" you are.

If you've ever downloaded a script and read the installation instructions you'll have likely been told that you need to CHMOD a file to 666 or set the permissions to 755. So how does this set of numbers relate to the various groups of the typical Unix file protection system? Well, there are three numbers and three different types of permission...
So what do these numbers mean? There are three main reasons why a person may want to open a file; to read from it, to write to it or to execute it (i.e. run it or use it). Each of these properties has a value assigned to it, and it is the sum of these values that determines the permission settings.
| read | write | execute | |
| permission value | 4 | 2 | 1 |
Once you know the permission settings for a file, you can determine exactly who is allowed to do what to that particular file by doing some simple maths. Here is a table showing which file attributes need to be set for all possible values of a setting.
|
So, following this table we can see that a file whose permissions are to be set at 755 will allow...
|
In this case everyone has access to read the file and run the program (assuming it was a script), but only the owner of the file can write to it (via FTP or shell access).
Another point to remember is that you are only considered the owner of a file when you access it via a shell account or FTP (both of which require you to log in to be able to identify yourself). If you are testing a script you have uploaded and you are using a browser to do it, then you do not have the owner's privileges, rather the results of the script will depend on the other user's permissions for the script and any files that are used for it. This is why it is common to set a script's permissions to 755 (which allows other users to read and execute the file) and its data-files to 666 (which allows them to read and write to the file)
Originally Published: Fri 7th Dec, 2001
The author, Rosemarie Wise, is a self proclaimed "web enthusiast" who set up her site,
Web Site Owner to share her experiences
of being a site owner.
