Setting File Permissions For Web Pages

 

    When posting web pages with your account, you may come across two types of errors.  One of these errors might be that the you are not using the correct file name when attempting to view your page in a browser.  The other might be that you have not correctly set the permissions of the files so that they are readable.

 

If you have any questions about any of the help provided on this page send email to labhelp@orzo.union.edu

 

Page Not Found

 

    If you are trying to view one of your pages and you getting the "Page Not Found" page.  This means that the server cannot find the page that you are trying to read.  Here is an example of what the "Page cannot be found" page.

 

 

    If this is the page that you see when you try to look at your pages, the reasons for this can be:

  • The address that you have typed is incorrect (notice the address is .htlm and not .html)

  • The file (page) that you're trying to get to does not exist.

    To avoid these problems, double check to see if you have typed in the correct URL and also make sure that the pages you are trying to access are uploaded and are in your "public_html" directory.

 

Page Is Forbidden

 

    The other error that occurs is that the file (page) that you're trying to access is "Forbidden".  Thus you do not have permission to view this file.  The page that comes up looks like this:


 

    When this occurs, it means that you have typed in the right URL for the page, but you are unable to read it because the owner of the page has not set the permissions of the file to a setting that allows browsers to view it.  In order to fix this problem, you must change the permissions of the file.  There are two ways to change the permissions, you can do it graphically using the Secure Shell File Transfer Client or you can do it through the Linux command line.

 

Changing Permissions Graphically

 

    If you wish to change the permissions graphically, log in to your account using SSH.  Next, click on the "New File Transfer Window" located on the top row of icons.  It is also possible to start the Secure Shell File Transfer Client by clicking its icon from Start --> Programs.  Once logged in open up your public_html folder on the right side of the split screen.  Now that you're in the public_html folder, you can set the permissions of the file.  Highlight the files that you want to post.  Then right click and go to "Properties".  A new window called "File Properties" will come up.  Here is where you change the settings. 


 

     There are three types of viewers for files.  These are the owner of the file, the group owner of the file, and  everyone else.  In order for a browser to view a website the file must be readable by the "Other" group.  The file should be readable by all three groups but writeable only by the owner of the file.  You change the settings by clicking on the boxes.  At the bottom, you will notice the "Permission mode" box change numbers as you click and unclick boxes.  If you already know that number code that you want, you can just type it in.  The standard code for web pages is 644 which gives read/write privileges to the owner and just read privileges to everyone else.  It is important to note that if you have folders inside your public_html folder, you must change the permissions of both the folder and the files separately.  Folders must be set to 755 and the files in the folders should be set to 644.  Also, if you are using executable files, scripts, you must set their permissions to 755 as well or just give the three groups executable privileges.  Once you have done this, the pages should be available to anyone who wishes to see them.

 

Changing Permissions From Command Line

 

    Once you're logged in, you can change the permissions of your files from the command line.  First, change directory (using the cd command) to your public_html directory.  Note that "public_html" is only a link to another folder located in /export/www/student/(your username).  Once here you can run "ls -l" to see the permissions on the files that you have in the folder.

     There are three types of viewers for files.  These are the owner of the file, the group owner of the file, and  everyone else.  In order for a browser to view a website the file must be readable by the "Other" group.  The file should be readable by all three groups but writeable only by the owner of the file.  The standard code for web pages is 644 which gives read/write privileges to the owner and just read privileges to everyone else.

     Thus to give the index.html file the 644 permissions you would type on the command line
        chmod 644 index.html
and for the cgi-bin folder you would type
        chmod 755 cgi-bin

 

  It is important to note that if you have folders inside your public_html folder, you must change the permissions of both the folder and the files separately.  Folders must be set to 755 and the files in the folders should be set to 644.  Also, if you are using executable files, scripts, you must set their permissions to 755 as well or just give the three groups executable privileges.  Once you have done this, the pages should be available to anyone who wishes to see them.

    

     On the leftmost side of the table, you will see a set of characters.  These characters represent the permissions assigned to each of the files.  If it is a directory, there will be a d at the beginning of the permissions.  Excluding the leftmost character, the first 3 spaces present the permissions of the owner, then the group, and then everyone else.  To change the permissions of file use the chmod command.  With this command, you must also use a set of numbers, the new permissions, and the name of the file that you are changing.  If you're setting the permissions for a number of files, it is sometimes quicker to use the * character.  If left like this, it will apply the command to all the files in the folder.  But if you use *.html, it will change only the file ending in ".html".  Web page files (such as: .html, .jpg, .gif) should be set to 644 with folders and executable files being set to 755.  Below is an example of the the changes made with the command line.


 

    

Once you have done this, the web page should be viewable.



If you have any questions about any of the help provided on this page send email to labhelp@orzo.union.edu