The following is information, tutorials, and help links for tools that we will use in for remote course activites and course work. More course-specific information is available off the CS 44 webpage, and from individual assignment pages.
Remote Access and Code Envirnoment Tools:
ssh and scp
ssh is useful for remotely logging into the CS lab machines. scp is useful for copying files between your local system and the CS system.
You can remotely connect to any machine by sshing in as you to
lab.cs.swarthmore.edu or to a particular machine by logging in as you
to a specific
machinename.cs.swarthmore.edu. For example:
# log into some lab machine: ssh email@example.com # log into owl: ssh firstname.lastname@example.org
You can find the names of lab machines here: cs lab machines
scp is like the cp command, but for copying files between two different machines.
# copy a file named "bio.txt" from the "cs44/labs/lab01" directory on a lab machine to your machine scp email@example.com:cs44/labs/lab01/bio.txt . # copy a file named "bio2.txt" from current directory on your machine onto a lab machine # Note: by default, this will place the file in your home directory; i.e., "/home/yourusername" scp bio2.txt firstname.lastname@example.org: # copy a file named "bio3.txt" from current directory on your machine onto a lab machine in the "cs44/labs/lab01" directory scp bio3.txt email@example.com:cs44/labs/lab01
ssh and scp links
tmux (and screen) are used to start sessions on a machine that you can detach from and keep running when you log out and then re-attach to later.
tmux is particularly useful for setting up an environment for remote lab work on a particular CS lab machine. You can then detach from the tmux session and logout, and later ssh back into the machine, re-attach to the tmux session and continue from where you left off.
tmux is also handy in that it allows you to create multi-panned windows in a single tmux session. For code development is it nice to have at least two panes: one for editing the file, and another for compiling and running. The CS department help pages has some information for getting started using tmux: CS help tmux page. Here, also, are a few basics:
## tmux commands from bash shell $ tmux # create a tmux session $ tmux attach # attach to an existing tmux session $ tmux ls # list existing tmux sessions $ tmux attach -t sessionname # attach to tmux session named sessionname $ tmux kill-session -t sessionname # kill tmux session named sessionname ## tmux commands from within a session CNTRL-b initiates these ## first type CNTRL-b then one of the following keys to do: CNTRL-b d # detach from the current session CNTRL-b an_arrow_key # to move to a different pane within a session CNTRL-b : # get tmux prompt to enter all kinds of commands # (ex. to create and configure panes)
Scrolling and copy/paste within a pane is a bit weird. Here are some commands for doing both:
# to scroll within a pane: CNTRL-b [ # then use page-up and page-down to scroll in pane # to copy from one pane only: CNTRL-b [ # to copy from a pane: space # start copying from curser # move curser to end of what you want to copy enter # stop copying at curser # to paste into same or different pane (be in insert mode if pasting in vim): CNTRL-b ] # paste
writing and using bash scripts to create custom tmux session:
It is often useful to write a bash script for creating a tmux session with a regularly used tmux set-up. Professor Newhall has an example script (mytmux.sh). that sets up a tmux session with 3 panes. It is designed to be useful for code development and testing, where the left-most pane can be used to run an editor (e.g. vim) to edit a source code file, and the right panes are useful for compiling, running, debugging, and other purposes. The script, when run, produces a tmux session that looks like this:
you can run the script directly like this to start your own tmux session using this configuration:
or you can copy it over into your home directory, and edit as you’d like, and run it to start your own custom tmux session (really 2 panes might be enough and easier to manage):
cd cp ~newhall/bin/mytmux.sh . chmod 700 mytmux.sh # set this to executable ./mytmux.sh # open in an editor (vim, emacs, ...) to edit the file to customize # in a different way (we find that 2-3 panes is useful, and more than # that starts to make the session more difficult to use): vim mytmux.sh
avoid leaving old tmux sessions running
When using tmux (and screen), be careful about not leaving a lot of old
sessions of yours running on lab machines. If you ssh into a
particular machine each time you run tmux or screen
tmux resources and links:
finding good/idle/undercommitted machines to use in our system
If you are ssh’ed into a lab machine and notice that it is running slowly, not responding well, you will want to find a better machine to use.
Here are few utilities to see what is running on a machine and to help you find another machine that will respond better and ssh into that one instead.
getting usage info on a machine (who, and top (and htop))
First, you can run
who to see if there are a lot of other users logged into
the same machine as you are:
If there are a lot of users logged into a machine, it may be one that could become overloaded. If all the users are idle, however, it will not be.
A better way to see real cpu and memory load on a machine is to
htop. htop has nicer output, so I’d recommend that:
htop shows CPU usage on each core, maybe 1-12 on one of the lab machines, Mem usage, and Swp usage. If the CPU and/or Mem usage is high, and particularly if the machine is Swapping (Swap is active), you want to pick another lab machine to use. Here is some more information about using top and htop
tools for finding a good machine(s)
smarterSSH to find a good lab machine to use
smarterSSH can be used to ssh into a machine that has a lot more available
RAM and CPU resources, and should perform well. Running it directly will
ssh you in to a good machine, but you may want to run using the
command line option to list the top machines, then exit the slow machine
(kiling any tmux sessions on it first), and then directly ssh into it
Here is the way you may want to run
smarterSSH -i -v -n 20
This lists the best 20 machines in terms of available RAM and CPU. Choose one of the machines listed to ssh into (you don’t always want to pick the top one, as maybe others are also choosing it, but if you select one in the top 10 or so, it should perform well)
Here are some other sample line options for using
# directly ssh's you into one of the best machines smarterSSH # list the command line options smarterSSH -h # lists top 50 machines based on their available RAM # probably want the default that orders based on a function of RAM and CPU smarterSSH -i -v -n 50 -m # lists top 50 machines based on their available cpu smarterSSH -i -v -n 50 -c
autoMPIGen is a tool similar to smarterSSH that automatically generates an MPI host file using PeerMon data to find good hosts. If you are using MPI on our system, this is useful tool for creating a hostfile of good hosts on our system. here is some more information about autoMPIGen.
system dashboard for machine stats
You could also look at the status dashboard off the CS department machines page to try to find a machine that looks less loaded.
links to more info:
Tools for lab work
Piazza and GitHub
As in most CS courses, we will use piazza for Q&A and github for lab assignments. Here are the links to the CS 44 piazza and github orgs:
For course work you should set up a course-specific subdirectory in your home directory. First read the resource about ssh about remotely connction to the CS system, then create ssh into our system and create a subdirectory for cs44:
# from home ssh into a cs lab machine: ssh <yourusername>@labs.cs.swarthmore.edu # on the CS system: $ cd # change current working directory to your home directory $ pwd # print current working directory $ mkdir cs44 # create a new subdirectory named cs44 $ ls # list contents of current working directory (your home directory) $ cd cs44 # change current working directory to cs44 $ pwd # print current working directory
Using Unix and Useful Commands and Resources:
vim (and vi)
The vi (and vim) editor is available on every Unix system. It is a very efficient and lightweight text editor that is easy to use after learning a few basic commands, which that you can learn by running though the vimtutor tutorial.
vim is particularly useful when working remotely, ssh’ed into a machine.
Vi (vim) also has a lot of advanced features that are very nice, and
is very configurable, often through the use of a
.vimrc file. However,
just a few basic commands is enough to use vim to edit files on our
Learning vim (and vi)
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 insterpreted as vim commands, which allow a user to do such things as saving, exiting, searching, or moving around in the file.
In insert mode to switch to command mode by hit the
In comand mode there are many ways to switch to insert mode, one is
to hit the
To learn the vim editor, run vimtutor:
home$ ssh firstname.lastname@example.org cs$ cd cs44 cs$ pwd cs$ 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)
You do not need to configure vim in any way to use it on our system. However, you may want to based on foreground and background terminal colors, and set some other options
In your home directory you can add a configuration file for vim, named
.vimrc. On start-up, vim examines this file to set different configuration
options for the vim session, including setting a color scheme, and default
To see if you have one already, run
ls -a in your home directory to list
all your dot files:
cd ls -a
If so, you can open it in vim and edit it like any other file:
If not, it is often easiest to start with someone else’s
and then edit what you want. From your home directory, you can copy
someone else’s. Here is one you can copy over into your home directory
that uses a color scheme that shows up well on dark background windows:
cd cp ~newhall/.vimrc .
At the bottom of this .vimrc file are some settings to give you a visual cue about not line wrapping source code in files. One sets the widowsize to 80 (or 81) chars when you start vim, others can be used to set visual reminders when a line exceeds 80 chars:
tail -20 .vimrc # dump the last 20 lines of the file .vimrc # note lines that start with double quote are comments set colorcolumn=80 highlight ColorColumn ctermbg=darkblue " resize to 81 to more easily see colorcolumn (set to 80 if don't use colorcolumn) set columns=81 autocmd VimResized * if (&columns > 81) | set columns=81 | endif set wrap set linebreak " visually shows +++ when go past columns limit set showbreak=+++
You can copy this into your .vimrc file if you’d like this functionality
Vim Resources and Links
Remote Lecture, Lab, and Office hours
These are tools that we will use for lecture, lab mettings and office hours in CS 44:
You will receive an email with information about how to find our class zoom link before the start of class.
There are instructions for using zoom off the college’s Working Remotely page.
Try it out:
Set-up and try out a zoom meeting with your lab partner or project group members
one of you should create a zoom meeting for your lab work:
Name the meeting something like
labXmeetingwhere X is the number of your lab assignment
Make it a Recurring meeting with the Recurrence→No Fixed Time option.
Enable join before host in the Meeting options
Save and send your lab partner the zoom link (Join URL associated with your meeting or copy the invitation link)
contact each other to find a time for a 10 minute practice zoom meeting.
at the time you arranged to meet, join your zoom meeting (because "join before host" is selected any of you can start the meeting).
You will receive an invitation to join the class slack page prior to the start of the semester.
Slack breaks up workspace into channels, which are listed in the sidebar on the left. Some channels we will use in this course are:
'#general' for general announcements about the class, you can select pinned announcements to find links to the course zoom page
'#office-hours' for class office hours. You can send a quick message to the professor here and start a zoom session to which s/he will attach.
'#lab-X' we will often move to slack after starting each lab session on the course zoom page. Here you can get individual help on your lab work, and we will check in with each lab group. You can type in short questions, but typically we will have you start a /zoom session to which we will attach.
To start a zoom session in slack:
First choose the slack channel for the type of session (lab or office hours), then you can start a zoom session to which the professor/lab instructor/TA/ninja will attach and help you with your specific question(s) or just check in with you. To start a zoom session just type '/zoom'. If you are working on a partnered lab one of you and your partner can start, and the other can join.
In zoom you can share your screen to display and run your code, or display your homework to your instructor.
The course staff is committed to making all course material accessible to you. To access Slack’s accessibility settings, start by clicking on the workspace name at the top of the navigation pane on a laptop or desktop.
Then from the dropdown menu choose “Preferences”, then select “Accessibility” from the navigation bar on the left.
Content magnification (“Zoom”). Allows you to enlarge content shown in Slack
Animation. Please uncheck this box if you are sensitive to animated images.
Keyboard. Options for non-mouse navigation.
To direct message someone:
By default, messages posted on Slack are visible to all members of the workspace. But for smaller conversations, you can use Slack’s direct messaging (DM) feature to start a private conversation with one person or a small group.
Code of Conduct
The course Slack workspace is accessed by a wide variety of people all working in different environments and timezones. We ask that you be respectful of the staff as well as your fellow students. We expect you to follow these general rules:
Do not use Slack to harass faculty, staff, or other students.
Do not spam any channels or direct messages with garbage. Try to make posts in academic channels concise.
Follow channel guidelines. E.g. do not post idle conversations in the #lab-X channel.
Respect others’ time. When you are in lab, or in office hours, try to respond promptly to messages directed to you.
Note that any messages you post in a channel will be visible to everyone in that channel. Think before you post!
If there is a problem where someone is violating the code of conduct or otherwise failing to respect others, please raise the issue to one of the class professors or instructors.
Here is some documentation on using slack
Here is some documentation on using zoom in slack (scroll past the how to install zoom to "Use Zoom in Slack" part)