Lab 0 - Unix Toolbox

This introductory lab is designed to introduce and familiarize you with many of the tools that we will be using throughout the semester. Most significantly, this lab will teach you the basics of working in a Unix/Linux environment, using the command line, writing and running programs on remote servers, and version control. Getting a handle on your working environment early on will save you lots of time in the long run and let you focus on the actual course material of the later labs.

0 - It's in the Syllabus

First, read the class syllabus so that you are aware of important course policies. If you have questions or need clarifications on anything in the syllabus, please let me know! Going forward, we will assume that everyone has read and is familiar with all policies and procedures detailed in the syllabus.

1 - Unix Crash Course

Go through the Command-Line Unix Crash Course. If you have never worked in a command-line environment before, this tutorial may take you some time. If you have some Unix background, you may already have seen most of this material (but you should still at least skim the tutorial to make sure).

A few parts of the tutorial involve short snippets of C code. Don't worry if you've never written any C code before; focus on the general ideas being illustrated (e.g., the process of using a compiler, the use of command line arguments, etc.) and don't get bogged down by the details of C at this point. We'll dive into the details of C later in the semester!

There is nothing to submit for this part.

2 - Setting up the Bowdoin VPN

Bowdoin IT has set up our class server so that you can only access it from Bowdoin's networks. In terms of WiFi networks, this includes "BOWDOIN" and "eduroam" but not the "BOWDOIN-GUEST" network. As a consequence, you normally will not be able to access our class server off campus.

At some point, you likely will want to do your class work off campus. To do so, you will need to install and connect to Bowdoin's VPN (virtual private network). When connected to Bowdoin's VPN, you can access our class server as though you were still on Bowdoin's networks. Install Bowdoin's VPN now. It is easier to debug any problems now (e.g., by dropping by the Bowdoin Tech Hub) while you are on campus than when you are off campus with a rapidly approaching deadline.

There is nothing to submit for this part.

3 - Accessing the Class Server

You have been provided with an account on krebs that will allow you to log in and work on your labs. You should access your server account by SSH key. For instructions on using your key, refer to the relevant section of the Unix tutorial. Make sure that you are able to log in to your account on the class server using your key. If you have trouble, your first stop should be the Unix tutorial. After that, you should ask for help via Slack or during office hours.

From this point on, all lab work in this course should be done on krebs unless otherwise noted. The class server provides a full-fledged Linux environment with all the standard development tools preinstalled (editors, compilers, version control, etc). If there is any software that you would like to use that is not already installed on the server, please let us know and we can probably install it.

There is nothing to submit for this part.

4 - Learning Vim

We will be learning how to use Vim, a very popular text editor that is preinstalled on most systems you might ever need to use. Run the vimtutor command and complete Lessons 1.1 through 1.4.

Although in this class we will be performing lab assignments on krebs, note that vimtutor and vim come preinstalled on Macs and most Linux distributions, so you can also use these programs even when you're not connected to krebs.

You will want to revisit vimtutor from time to time throughout the semester. I still do, and I still learn something new each time! After completing the vimtutor, you will have learned that in Vim, we refrain from using the arrow keys for basic motion. Instead we use hjkl (left/bottom/top/right) because they don't require us to move our hands. To help cement these motions into our muscle memory, consider playing some games! Have a go at downloading and running the turn-based Bowdoin Dungeon Crawler RPG game. Once you are comfortable moving around in that game, try playing something realtime like the ANT tetramino game.

There is nothing to submit for this part.

5 - Sanity Check

Finally, you will complete a few simple tasks on the class server to check your understanding and account configuration. The main objective here is to make sure that all configuration-related issues are dealt with now, as opposed to right before the first 'real' lab is due.

Your task is to use Vim to write a very simple C program and an associated Makefile, then submit them using the krebs submission script.

  1. Inside of your home directory will be an assignments directory. First cd into the directory and then type ls. You should see lab0. (Other assignments will also appear here later in the semester.) Then cd into lab0. The only starter file in this directory will be a README.md file.
  2. Inside your lab0 directory, use Vim to write a program called like.c that simply prints the message "I like [xyz]!" where [xyz] is the first command line argument. If the program is not given any command line arguments, or is given more than one, it should instead print "What do I like?". Here are a few examples, assuming the executable compiled from like.c is named like:
    $ ./like pizza
    I like pizza!
    $ ./like Linux
    I like Linux!
    $ ./like
    What do I like?
    $ ./like Linux pizza
    What do I like?
    $
    
    If you've never written a C program before, just use the example in the Unix tutorial as a starting template and modify that; you don't need any further knowledge of C to complete this part.
  3. Write your name in a comment at the top of your program. Comments in C have the same syntax as Java (single-line comments start with //).
  4. Use Vim to write a Makefile for your C program. Your Makefile should have two targets: the default target (which should be named like) which compiles the program into an executable named like, and a clean target that deletes the compiled files (which in this case is just the like executable). Follow the Makefile example given in the Unix tutorial. Put your name in a comment at the top of your Makefile (comments in a Makefile start with #).
  5. Once your program is finished, you should be able to run the following set of commands from your lab0 directory to compile your program, run it, and then clean up (at which point you'd need to run make again before you could run the program again):
    $ make like
    $ ./like systems
    I like systems!
    $ make clean
    $ ./like systems
    bash: ./like: No such file or directory
    $ make
    $ ./like make
    I like make!
    

6 - Submission Script

To submit your assignment, run the submit command. You are not required to do all of your work inside of the originally provided lab0 directory. However, the submit command derives the name of the submitted assignment from the name of the current directory, and so whatever directory you ultimately submit from should be named lab0. Note that you may submit as many times as you like, and only the final submission will be graded.

Verify your submission by listing your submitted files using the submit-ls command. It again derives the name of the listed assignment from the name of the current directory.

Evaluation

This lab will be marked pass/fail only based on the following criteria:

  1. Does your like.c program follow the specification above?
  2. Does your submission include a Makefile with both the default like target and a clean target?
  3. Is your name included in a comment at the top of your source code file?
  4. Were your files written using Vim on krebs?