1. Due Date
-
There is a soft deadline for this lab for Thursday, September 7, 2023. This is just a warm-up lab, and does not have an assigned greade.
-
This warm-up lab 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 Friday.
-
We will also assist you with questions on this lab, during the lab session on Friday. 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, and EdSTEM.
-
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 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
[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 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:
-
insert mode: keystrokes are interpreted as inserts into the file contents at the point of the cursor.
-
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
:
-
ssh into our system and run
vimtutor
. Consult the help pages on remote access and ssh if needed. -
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
-
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)
-
5.1. Vim Resources and Links
6. Sign into EdSTEM
We will use EdSTEM to help answer questions and post announcements. Try signing in and let us know early if you have any trouble connecting.
7. Set up your Swarthmore GitHub account
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. |
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 this excellent visual introduciton to Git and the Git Overview and Setup and Configuration sections of the Git Help page
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
[cs31]$ cd labs
[labs]$ git clone git@github.swarthmore.edu:CS31-F23/Lab0-userID.git
[labs]$ 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.
[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 Lab0 repo until Monday afternoon.
We will go over these steps in lab on Friday, 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.