1. Due Date

  • This lab will not be assigned a grade, but it contains instructions and tools necessary for starting and submitting Lab 1. You should try to complete it prior to the start of your lab session on Wednesday.

  • We can assist you with questions on this lab, but if you have not started it prior to the start of your lab session, we will ask you to read this page while we first assist others that have done so.

2. Lab Goals

  • Log into the CS lab machines

  • Reset your password, if necessary

  • Set-up course tools and resources, including git, Ed, and Slack

  • Learn the basics (or refresh your knowledge) of Unix and useful Unix commands/tools

  • Learn the basics of a text editor, if you don’t already know one

3. New User Setup

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.

  • Read the CS lab rules and user rules off the CS help pages

  • 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 "log out".

  • Attend one of the Using Unix Sessions

4. Create a folder

Setup a directory for your cs31 work.

If you have not already done so, first create a cs31 subdirectory in your home directory and cd into it. Start a terminal and at the prompt ($) enter the following command sequence. 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
  $ pwd                # print current working directory

Here is some information about the Unix directory structure.

5. Learning an editor (if you don’t already know one)

If you do not already know another editor (e.g. emacs, atom), you should learn the basics of vim. However, if you are already comfortable with another editor, you can skip this section.

This section also has a short walkthrough video that may be of assistance if you get stuck getting started with vim:

The vi (and vim) editor is available on every Unix system. It is 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.

It will be important to know the basics of vi/vim for some upper-level systems (Group 2) courses.

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 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
      $ pwd         # print working directory to show full path

    From within your cs31 subdirectory run the vim tutorial:

      $  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)

Optionally, you can configure vim for better course use. You can also consult the remote tools page throughout the semester for more information on using various CS31 tools.

6. Sign into Ed and slack

We will use both Ed and Slack to help answer questions and post announcements. You should have received email invites to each service. Please sign in to both accounts and let us know early if you have any trouble connecting.

7. Set up your Swarthmore GitHub account

We will be using Swarthmore’s GitHub Enterprise to get and submit lab assignments. If you previously took CS 35 at Swarthmore, you have used the same tool and you can skip the creation of ssh keys as long as you remember your ssh key passphrase.

Read the Git Overview and Setup and Configuration sections of the Git Help page, and then try cloning a copy of the Lab0 repo from the CS31 GitHub organization for our class.

All Swarthmore students should have a Swarthmore GitHub account connected to your ITS username and password. You can login to do some of the initial setup steps at https://github.swarthmore.edu/.

If you get stuck in the next two steps, we have added two walkthrough videos covering the steps below that may be of assistance:

7.1. Add SSH keys

If this is your first time using the college’s GitHub server for CS, follow the ssh-keys and config steps link from the Setup and Configuration directions for information on how to generate ssh keys and upload your public ssh key (generated from your CS account) that is necessary to clone repos on our system. 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. Add your public key as a new SSH key on your Swarthmore GHE key settings.

7.2. Clone Repo

Once you have added your key, you should be able to clone your repo on the CS network. This step 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.

$ cd
$ cd cs31
$ cd labs
$ git clone git@github.swarthmore.edu:CS31-F21/Lab0-userID.git
$ cd Lab0-userID

7.3. Submit changes

If you successfully cloned the Lab0 repo, open the README.md file in an editor and follow the directions for editing the file and then committing and pushing your changes using git.

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

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

We will go over these steps in lab on Wednesday, but please try this on your own before lab. We will help you during lab if you get stuck completing these steps.

You will need to 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. There is no grade for Lab0, but it is a chance for you to practice the steps needed for future labs. You can log into GitHub and check on your repo to see if your changes are there. If they are on GitHub, you did the steps correctly.

NOTE: you need a CS account to do this. If you don’t have one, we will hand out new accounts at the end of class on Tuesday, or see Jeff Knerr outside of class to get your account.

8. Handy References