COSC 2P89
Introductory Lab

September
2017


COSC 2P89 Introductory Lab


For your first lab you are to get acquainted with some basic Unix commands and the creation of a simple web page. The student on duty at the help desk will assist you with the following tasks if you require assistance. Although you will most likely create your web pages on your personal computer in the future, you should restrict your activities to sandcastle for this lab. It is important to gain a comfort level with a command line Unix environment and this simple lab is an excellent way to become more comfortable.

For this lab you should type in a simple web page on sandcastle and view it with a web browser.

If you need assistance in any of the tasks consult with the student on duty at the help desk.

  1. Login to sandcastle using a secure shell program (ssh). One example of such a program is putty which is freely available on the internet and hopefully is installed on the lab computers.
  2. Create a text file using the pico editor by using the command "pico myfile.txt". Just type in a couple of lines of text and then save the file. The simple editor commands are visible at the bottom of the window. For example you will see ^X Exit at the bottom left of the window. If you have modified your file you will be prompted to Save Modified Buffer. If you enter "y" you then have a chance to save your file to the new or existing file name or save to a different file. Pico is a very basic, simple to learn editor. A more powerful Unix editor is vi.
  3. After you have created a file try out some basic Unix commands, such as cat, less, ls, mkdir, rmdir, cd, cp, mv, rm, and passwd.
    cat is for displaying text files
    less is for displaying text files page by page with the ability to scroll within
    ls is for listing file and directory names
    mkdir is for creating directories
    rmdir is for removing directories
    cd is for changing your current directory
    pwd is for displaying your current directory
    cp is for copying files
    mv is for moving files
    rm is for removing files
    passwd is for changing your login password
  4. These are just a few of the commands you will find useful at the Unix command line. You can obtain online help on these and other commands by using the man command. You can also look at the Unix Reference, also linked from the course home page.
  5. Note that for many commands there are switches that allow you to control some aspect of the command. For example with the file and directory listing command ls there is a switch -l such that is you enter "ls -l" you get a long directory listing in which ownership, size, and permissions are displayed rather than just the file names alone. For the commands above you would be advised to explore some of the swithes with the man command. So man ls would give you lots and lots of informations regarding the ls command including the valid switches.
  6. On sandcastle the web server is configured to require that your web pages be stored in a sub-directory of your user directory, and this directory must be named public_html. Create the public_html directory for your web pages using the mkdir command.
  7. You need to ensure your student directory and your public_html directory have the correct permissions to allow the web server to access your html files.
  8. From your default login directory type chmod o+x ../aa99zz where aa99zz is replaced by your userid.
  9. Assuming you have created the public_html directory type in chmod o+x public_html
  10. As mentioned in class a web server runs as a regular program and does not have special privileges. Thus you must ensure that the files in your public_html directory are accessible to the web server. You will need to use the command chmod that changes file permissions.
  11. Experiment with chmod. Rather than memorize specific values, such as chmod 711 myfile.txt, keep in mind the underlying nature of the command. You can use chmod with =, +, - to assign, add, and remove permissions respectively. The permissions rwx are mapped as bits and there are 3 groups of these:u (user or owner), g (group), and o (others). So chmod 741 myfile.txt is equivalent to chmod u=rwx,g=r,o=x myfile.txt or to add read access for others you can use chmod o+r myfile.txt. Practise with chmod.
  12. Position your working directory to be public_html and type in a simple web page that displays Hello World in the body.
    <!DOCTYPE html>
    <html>
    <head><title>First Page</title></head>
    <body>
    <h1>Hello World!</h1>
    </body>
    </html>

    Save and name the file first.html.
  13. Bring this page up in a web browser. (www.cosc.brocku.ca/~xxxx/first.html where of course xxxx is your student directory).
  14. Make a copy of this file with the cp command and named as default.html. Make a small change to it so that the web page now displays Hello Again World!. To view this page you do not need to specify the default.html file name because default.html is a file name used by the web server when no file is explicitly given. (www.cosc.brocku.ca/~xxxx)
  15. NOTE: Keep in mind that ALL assignments, including the final assignment, must be stored on sandcastle for proper assessment during the term so make certain you are comfortable with sandcastle. Doing your work elsewhere and then encountering difficulties in porting it to sandcastle will not be a means of getting an externsion.

Computer Science Department | COSC 2P89 Home