The AceHostNet knowledgebase is a growing collection of
support information which is generated by us and our users
for our users. By keeping this collection of support
growing, our customers are helping us create the most
detailed and complete collection of support documentation
possible.
A: The path is:
/home/USERNAME/public_html/SUBDOMAIN/cgi-bin
Replace USERNAME with your login name, and SUBDOMAIN with the SUBDOMAIN.domain.com part of the subdomain.
A: So you have found the coolest CGI script to add to your already cool web site. You upload the new script to your site. With the excitement building, you test it out. Instead of seeing the output of the script, you get 500 - Server Error. What is wrong? You were told it would work with your web hosting provider. The major culprit is that you did not set the file permissions for your new script correctly. You look at the readme file the came with the script and it states you that you must change the permission set on one file to 655, others to 755. What does it all mean?
The purpose of the tutorial is about how to set UNIX file permissions and how it exactly works.
UNIX file permissions, or more commonly known as "Chmoding", is a set of permissions used by the UNIX/Linux operating systems which controls who and what will have access to files on your site. Chmoding is used in both restricting access to certain files and setting the permissions so a CGI program may perform the task it was programmed to do. There are only three levels of permissions on the UNIX/Linux OS.
They are the permission to:
* (r) Read,
* (w) Write and
* (x) Execute files or programs.
With these three permissions there are three groups in which they apply to. The three groups are:
* Owner,
* Group and
* Other or also known as world.
The owner applies to who actually owns the files (your account). The group applies to the GID or the Group ID Number of the server you are on (everyone on your server) and Others or World applies to everyone else. Each group must have its access properly set for the file to be used and accessed.
These permissions allow the script to be able to run and edit or create the files it needs to do its operation. Chmoding is also useful if you wish to restrict outside web access to certain directories or if you wish to set a file to where no one but you can access and modify it.
As I said earlier, there are three types of access; read (r), write (w) and execute (x). In order to easily set these permissions, each permission is assigned a number.
Here is a chart of the permission numbers:
r (read) w (write) x (execute)
4 2 1
Ok, now that we have the basic numbers. But what happens if we want to be able to read, write and have execute access. Just add up the numbers. If read=4, write=2 and execute=1 then we add 4+2+1=7. Here is a chart to demonstrate this practice:
Type of Access
0 = no access
1 = execute only
2 = write only
3 = write and execute (1+2)
4 = read only
5 = read and execute (4+1)
6 = read and write (4+2)
7 = read and write and execute (4+2+1)
Remember earlier we said there were 3 groups (Owner, Group and Other). We must correctly set permissions for each one. How you do this is you figure out what permission(s) you want for each group and combine the numbers.
Example: Say we want the owner to have read, write and execute access, the Group to have read access and Other to have no access. Owner would be 6 (4+2), Group 4 and Others would have 0. Now all we do is combine these numbers (in the order of Owner-Group-Other) to come up with 640. Most commonly files are set at 644 permission which allows the owner to read and write the file and the group and world to only read the file.
Here are some other examples:
user group others
655 rw- r-e r-e
754 rwx r-x r--
664 rw- rw- r--
Now you have an understanding of what CHMOD is and how to determine the correct sequence. How do you change a files access attribute? There are a couple of ways:
# If you have TELNET access to the server you can go to the directory where the file is located and type; chmod mode filename.
# Some FTP programs offer this feature. Cute_FTP offers this by right clicking on the file you want to change and selecting "change file attribute". Most FTP programs offer this, but you will need to check the documentation that came with the program.
Important Note: You should not permit a file or a directory with write permission for members of your group or all other users, as this will hazard the security of your own files, and may provide a means of entry to the UNIX file system that causes more widespread damage. You should check the file modes of all files and directories, including those files whose names begin with a dot(.).