HW2: In The Beginning Was The Command Line

25 points; due Mon 4/7 @ 9am.

Goals

The goal of this homework is to get you used to using the computers here in the labs, and getting started with one of our main tools.

1. Setup and Requirements

While you may be able to work on homework assignments on your personal computers, it's worth while to learn how to use the lab computers and the tools on them. You'll need to be able to log in to the CS computers in CMC 102, 304, or 306. If you are having trouble logging in, contact Mike Tie or one of his minions in CMC 305.

2. Your Task

What is a “Command Line”?

Although the computers in our labs are Apples, we will be using a particular tool on these computers that you may not be familiar with, known as the “Command Line”.

In the olden days of computing, around 1960–1970, there weren't fancy displays. Most computer monitors were only capable of extremely simple graphics, and generally they were restricted to displaying only fixed-width alphanumeric characters, 25 lines at a time, 80 characters per line.

Therefore, the entire interaction was by typing the names of commands into this window, then pressing “Return” to run the command. Imagine that every time you wanted to run Firefox, you had to type “Firefox” and press enter. That's how it all worked. (Of course, there wouldn't have been any program with graphics as fancy as Firefox, but that's beside the point.)

It may sound terrible, but it was (and still is) an essential tool for a programmer. Although it may be hard to believe, there are certain interactions that are much easier in a command line interface than with the Mouse-and-Graphics interface that you are used to.

In fact, if you're interested about the history of the early days of computer interaction, and the first 30 years of operating system evolution, you can download and read an entertaining version titled In the Beginning was the Command Line. (This is in no way required for this assignment or the course, it's simply interesting.)

To learn the command line, log in to one of the CS lab machines in CMC 102, 304 or 306. Some of the computers in these labs are set up to boot into either Windows or Max OSX. If the computer you choose is showing a windows login screen, you'll need to restart it. If it is showing a Mac login screen, go ahead and log in.

Once you have logged in, run the Application Terminal. (It should have a shortcut in dock.) This will open up small window that displays text characters — specifically, it is 80 columns by 25 lines. In the window you'll see something like this:

Last login: Mon Mar 31 10:22:04 on console
skittles:~ jadrian$

Voila! This is your command line. The first line of text there is just telling you where you last connected from. The second like of text is known as the prompt. There is actually a lot of information in that cryptic line: It is telling you your computer's name (in my case, skittles), your current directory (~, which is a special name for the current user's home directory), and the current user (jadrian).

Now, load up the CS department's Unix tutorial and go through Typograhical Conventions, Introduction to the UNIX Operating System, and Tutorials 1–4.

The tutorial was originally written for the Unix operating system and for students at the University of Surrey (note British spellings), but it is still accurate enough for us. One difference is that on their system, the final character of the prompt is a %, but on our systems it is a $. So all their examples of what to type begin with a % character. Don't type this into the command line. It is simply an indicator of what the prompt looks like.

3. Self-Test

By the end of the tutorial, you should be able to walk comfortably through the following steps:

  1. Log into your account on a Macintosh (your own or one of the Macs in the CS labs: our classroom or on the third floor of the CMC).
  2. Launch Terminal.
  3. Create a subdirectory of your home directory to contain your work for a CS 111 assignment, say “hw02”.
  4. Change directories to your new directory.
  5. Launch TextWrangler or some other text editor and create a simple python program containing:
    print 'Hello, World!'
  6. Save your program as “hello.py” in the new directory.
  7. Back in the Terminal, run your program with the command python hello.py.

You don't have to turn in anything for this step, but all later homework assignments will assume that you can do the above independently. Bring any questions you have to class, and/or post on the Piazza.

4. Submission

Submit the biglist file that you created in Tutorial 3 via Moodle.