Unix Homework

Homework to create a structure of folder (directories) and files in your Unix account on Tempest. You can also create a similar structure on your laptop, but I won't be able to check that.

Purpose

Working with folders and files is not hard but it's an essential skill. Students in CS 304 sometimes stumble at the beginning of an assignment, needing help in copying the requisite files and folders, dealing with errors that occur, and setting things up correctly.

I don't mind helping with those steps, but it's more empowering for you to not need help.

Terminology

On Unix systems, the word directory is the standard term, with folder being a more recent synonym. I like the alliteration of "files and folders" but I also like the tradition of "directory". Furthermore, the word "directory" makes commands like "cd" (change directory) and "pwd" (print working directory) clearer.

The words are perfect synonyms, though, so don't let this confuse you.

Reference

All the skills for this assignment are covered in the unix reference and the Google Presentation on Unix.

Time

Historically, this takes almost everyone less than 3 hours to complete. If it's taken you that long and you're not done, stop and get some help.

Task Overview

You'll set up some files and folders for your use in this course. There will be some extra files and folders in there, just for the purposes of this assignment.

You'll also create a tarfile and submit it for grading.

Structure to Create

In your home directory, create some folders for this semester. The following is indented to show structure. Anything ending with a slash is a folder. Files will have a dot in their names. The part after the dot is called the extension and usually denoted the type of the file, such as HTML, CSS, JS, PY, etc.

cs304/
    node/
    apps/
        app1/
            public/
                style.css
                stuff.js
            views/
            server.js

Structure to Copy

The above are all empty files. Here, you'll copy some files from the cs304node course account. Specifically, you'll copy files from the public_html directory that is in the cs304node account.

  • Both files to copy are in downloads/basic-web-page/.
  • Find those files and copy them to the public folder, above
  • Rename the html file to page.html

Files to Edit

Using VS Code, edit the page.html file.

  • Put your own name at the top in the appropriate places.
  • Add a bullet list of 2-3 movies you like.
  • Make the title of the movie a link to the IMDB page for that movie

I've assigned partners for this assignment. Each person will do the assignment (you should help your partner do theirs and they can help you), so it should be your own name in that file.

Checking your Web Page

Naturally, you'll want to check your web page, to see if you made any typos and to make sure it looks right. Intentionally, but unfortunately, this folder is not "on the web", so you can't view it. (The folder is intentionally not on the web because in our finished web apps, we don't want the user to be able to bypass our app and view files directly.)

What we can do is

  1. move the public folder to your account's public_html folder
  2. view the file using a URL like https://cs.wellesley.edu/~YOURACCT/public/page.html. But see note in the next section about possible permission problems.
  3. edit the file using VS Code until you are happy with it.
  4. move the public folder back to your app1 folder

Note that you can decide to copy the folder instead of moving it, but just make sure the resulting structure is correct.

Permissions Problems

By default, our files are only readable by ourselves (this default can be changed, but don't — it protects your privacy). In particular, the files will not be readable by the web server (Apache). If you try to view your page on the web and you get a 403 Forbidden or a 404 Not Found error, you should include permissions as part of your debugging.

The Unix chmod command can modify the permissions of files and folders in detail, but for your convenience I've created a command that will "open" a directory. You can do:

cd ~/public_html/
opendir public

and then try to reload the web page.

Copy a folder

We've done a bunch of set-up in app1, including creating a web page. I'd like you now to create a folder identical to it, as a sibling to it, called app2. Do this by a recursive copy.

Create a Tarball

This step creates the file you will turn in.

  1. Go to your home directory
  2. Create a tarfile of your cs304 directory tree. Call it unix.tar:
tar cf unix.tar cs304

Checking your Work

Before submitting your tarfile, you can use the check-unix-assignment command in the course public_html/bin directory. It takes your tarfile as a command line argument:

~cs304node/public_html/bin/check-unix-assignment your_tarfile_here

That script checks that your tarfile has all the required files in it, by comparing to one I created. However, if there are extra files in yours, say downloads from the second day of class, it'll report those differences. You can safely ignore complaints about extra files. But pay attention to anything that is missing or different.

Submission

Finally, use the drop command to submit your tarfile to the course drop folder. That command takes two command line arguments: (1) the name of course, cs304node and the name of the file, unix.tar. It looks like this.

[anderson@tempest ~]$ drop cs304node unix.tar 
Copying unix.tar (from anderson) to /home/cs304node/drop/ (uid 1942) 
Successful drop. 

Here's the command, suitable for copy/pasting:

drop cs304node unix.tar

Once you've submitted your tarfile, you can delete it, if you want.

Gradescope

The way I know that you are done and your work is ready for grading is when there is something in Gradescope. This also allows me to use a consistent rubric, and to have a list of students who have and haven't finished the assignment. So, for each assignment, I ask you to submit a Gradescope item. This is just a PDF that will be uploaded and associated with your account. Here's how:

  1. Create an empty Google Doc.
  2. Write in it a sentence like: I (Hermione Granger) worked on this. I dropped from my account: hgranger.
  3. It's helpful to remind me of the account name; I don't always remember the account that goes with your name.
  4. I can then grade the file you dropped, or the work in your folder or whatever
  5. Use the File menu to download the page as a PDF (or print it and save as PDF).
  6. Upload the PDF to Gradescope.