1. Due Date

  • The deadline for this lab is Thursday, Jan. 25. This is a warm-up lab, and does not have an assigned grade.

  • Completing this lab is necessary for starting and submitting Lab 1 (and all future labs!). Complete it before lab starts on Friday, so that you have your programming environment setup to fully participate.

  • In lab, we will help you with questions for this lab assignment. However, please make sure to read this page in its entirety before you ask us for help.

2. Lab Goals

  • Succesfully log into a CS lab machine

  • Sign in to EdSTEM and post a message

  • (Re-)familiarize yourself with basic Unix commands

  • (Re-)familiarize yourself with a text editor

3. New User Setup

Note: If you already have a CS user account, skip this step.

All work for CS31 will be done using your CS user account. If this is your first CS course at Swarthmore, you should have received an email from our system administrator, Jeff Knerr, with your username and a link to reset your initially random password. Please follow the directions to set/reset your password for your CS account.

  • Physically go to a CS lab and login with your new account. It will ask you to reset your password. To logout, click on the logout icon logout and choose "logout."

  • Attend one of the "Using Unix" sessions

4. New and Returning Users

5. Sign into EdSTEM and reply to a post

We will use EdSTEM to answer questions and post announcements. Sign in and reply to the "Welcome to CS31" post with your favorite food item. Let us know early if you aren’t able to log in.

6. Set up a directory for your CS31 work

Note: You must be logged onto a CS lab computer (either physically or through ssh).

The below sequence of commands will create a cs31 subdirectory in your home directory and navigate into it. Open up a terminal window and at the prompt ($) enter the commands below. (Do not type the $.The #'s are explainations of each command and also shouldn’t be typed.)

[~]$ cd # change current working directory to your home directory
[~]$ pwd # print current working directory
[~]$ mkdir cs31 # create a new subdirectory named cs31
[~]$ ls # list contents of current working directory (your home directory)
[~]$ cd cs31 # change current working directory to cs31
[cs31]$ pwd # print current working directory
[cs31]$ mkdir labs # create a new subdirectory "labs" inside the cs31 directory
[cs31]$ cd labs # change current working directory to labs
[labs]$ pwd # print current working directory

Here is more information about the Unix directory structure.

7. (Re-)familiarize yourself with a text editor

Note: If you don’t already know how to use a command-line text editor (e.g. emacs or atom), you should learn the basics of vim.

Real programmers set the universal constants at the start such that the universe evolves to contain the disk with the data they want.
Figure 1. Real Programmers (https://xkcd.com/378/). Real programmers set the universal constants at the start such that the universe evolves to contain the disk with the data they want.

The vi (and vim) editor is available on every Unix system. It’s an efficient and lightweight text editor that is easy to use after learning a few basic commands, which you can learn by running though the vimtutor tutorial.

Knowing the basics of vi/vim will be helpful for many upper-level systems (Group 2) courses.

You may want to watch this short walkthrough video in case you get stuck getting started with vim:

vim is particularly useful when working remotely over an ssh connection. vim also has many advanced features and is very configurable through, e.g., the use of a .vimrc file. However, just a few basic commands is enough to get you started.

Vim operates in two modes:

  1. insert mode: keystrokes are interpreted as inserts into the file contents at the point of the cursor.

  2. command or escape mode: keystrokes are interpreted as vim commands, which allow a user to do such things as saving, exiting, searching, or moving around in the file.

To switch from insert mode to command mode, press the ESC key.

There are many ways to switch from command mode to insert mode. One way is to press the i key.

To learn how to use the vim editor, run vimtutor:

  1. ssh into our system and run vimtutor. Consult the help pages on remote access and ssh if needed.

  2. After creating a cs31 subdirectory in your home directory in the section above, change into this directory with cd:

      [~]$ cd          # go to home directory from current directory
      [~]$ ls          # list (ls) home directory contents
      [~]$ cd cs31     # change directories (cd) to cs31 folder
      [cs31]$ pwd         # print working directory to show full path

    From within your cs31 subdirectory run the vim tutorial:

      [cs31]$  vimtutor     # start the vim tutorial
  3. Go through the sections listed below of vimtutor (the other sections cover more obscure features that are not necessary). It will take about 30 minutes to run through these lessons.

    • All of Lesson 1 (moving around, x, i, A, :wq)

    • Lesson 2.6 (dd)

    • Lesson 2.7 (undo)

    • Lesson 3.1 (p) and 3.2 (r)

    • Lesson 4.1 (G) and 4.2 (searching)

    • Lesson 6.2 (a), 6.3 ( R ), and 6.4 (y and p)

8. Set up your Swarthmore GitHub account

Note: You need a CS account to proceed with this step. If you don’t have one, email Jeff Knerr (knerr <at> cs <dot> swarthmore <dot> edu) to get your account.

We will be using Swarthmore’s GitHub Enterprise server (https://github.swarthmore.edu/) to retrieve and submit lab assignments for the entire semester. Note that this is a different URL than the public GitHub server (https://github.com/).

8.1. Learn about git

  1. Read this excellent visual introduciton to Git.

  2. Read the Git Overview and Setup and Configuration sections of the Git Help page.

8.2. Confirm access to Swarthmore’s GitHub server

Make sure you can log in to your Swarthmore GitHub account using your ITS username and password.

8.3. Add SSH keys

Note: If you’ve taken CS35 at Swarthmore, your GitHub account should already be set up. You can skip the creation of ssh keys as long as you have your ssh key stored.

Follow these instructions to generate your ssh key and connect it to your Swarthmore GitHub Enterprise (GHE) account so that you can access our course GitHub organization and the Lab repositories ("repos").

Alternatively, we’ve created a video that walks through the same steps here.

Make sure you are logged into the CS network via ssh before creating your keys. It is possible, particularly on a Mac, to create keys just for your home machine/laptop, but that is not the goal here.

8.4. Clone Repository

Once you’ve added your ssh keys on GHE, you should be able to clone your repo onto your CS lab computer. These steps will fetch a copy of the files from GitHub and copy them to your labs folder on the CS network. Replace userID below with your username.

We’ve created a video that walks through the same steps as below here.

[~]$ cd
[~]$ cd cs31
[cs31]$ cd labs
[labs]$ git clone git@github.swarthmore.edu:CS31-S24/Lab00-userID.git
[labs]$ cd Lab00-userID

For future labs, you can get the link to clone the repository through the following steps:

  1. Go to the repo that you want to clone

  2. Click on the green "Clone" button

  3. Make sure that the "Clone with SSH" option is selected

  4. Copy the link that is displayed

Screenshot of Github 'clone' button

8.5. Submit changes

If you successfully cloned the Lab00 repo, open the README.adoc file in an editor. Next, follow the directions in that file.

[lab0]$ git add README.md # make this file part of next commit
[lab0]$ git commit -m "updated readme documentation" # locally record changes with message
[lab0]$ git push # send changes to GitHub

NOTE: you will not be able to access our course GitHub org or your Lab00 repo until Tuesday afternoon.

You can log into Swarthmore GitHub Enterprise and check your repo to see if your changes have succesfully been puhed. If they are on GitHub, you did the steps correctly.

Remember to add, commit, and push each time you want to submit something for a grade. The push command sends files that have been added and committed to the GitHub servers, which is where graders and staff have shared access to your files.

9. Handy References