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 zip file 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
publicfolder, 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
- move the
publicfolder to your account'spublic_htmlfolder - 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. - edit the file using VS Code until you are happy with it.
- move the
publicfolder back to yourapp1folder
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 Zip file¶
You're now done. This step creates the file you will turn in.
- Go to your home directory
- Create a tarfile of your
cs304directory tree. Call itunix.zip:
zip -r unix.zip cs304
Checking your Work¶
Before submitting your zipfile, you can use the
check-unix-assignment command in the course public_html/bin directory. It
takes your zipfile as a command line argument:
~cs304node/public_html/bin/check-unix-assignment your_zipfile_here
That script checks that your zipfile 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¶
There are two parts to the submission; one is code I can run and process with command-line tools and the other is a submission to Gradescope.
For the first part, use the drop command to submit your
zipfile to the course drop folder. That command takes two command
line arguments: (1) the name of course, cs304 and the name of the
file, unix.zip. It looks like this.
[anderson@tempest ~]$ drop cs304node unix.zip
Copying unix.zip (from anderson) to /home/cs304node/drop/ (uid 7003)
Successful drop.
Here's the command, suitable for copy/pasting:
drop cs304 unix.zip
For the second part, copy your zipfile to your laptop, using SCP, and upload it to Gradescope.
Once you've submitted your zipfile, you can delete it. But there's no harm in keeping it, either.