This page does not represent the most current semester of this course; it is present merely as an archive.
Please work through these in order, as the first is most important and not quite finishing the last shouldn’t be too much of a problem.
Read and understand everything written on this page. Do the activities listed in exercise boxes like this.
You should be able to
portal.cs.virginia.edu
via ssh
ssh
without the need to re-type your password each time, see our ssh help sheet.
as meaning “the current directory”..
as meaning “the directory containing the current directory”~
as meaning “my home directory” – i.e., /u/lab/mst3k
If you are unsure of any part of this, please talk to a TA in lab. You take priority over people working on later parts of this lab.
Each directory has three permissions, called “read”, “write”, and “execute”.
ls
won’t work in the directory.
cd
won’t work into the directory and nothing will work with a path that includes the directory in the middle.
You can change permissions using the chmod
command. It has multiple ways to be used, but a few simple examples are
chmod a+r foo # all users can read foo
chmod o-x foo # out-of-group users cannot execute foo
chmod u+w foo # the owning user can write foo
Directories can contain other directories, and also can contain files. Files, like directories, have names and permissions but cannot be entered with cd
. The permissions also have different meaning than with directories:
Every user belongs to one ore more groups, and every file or directory has an owning user and an owning group. Permissions are specified as read/write/execute for the user, group, and others.
You can find out your user name with whoami
and your group memberships with groups
.
You should set up your home directory so only you can access it, not other people in your group nor strangers not in your group:
After ssh
ing into the CS server (i.e., ssh mst3k@portal.cs.virginia.edu
), run the following commands:
Warning: Be careful in typing. If you accidentally remove write access to yourself (via
a-w
oru-w
) you will not be able to fix it; we’ll have to contact the systems staff to do that instead.
cd # go home
chmod g-rwx . # remove group-access to read, write, and execute this directory
chmod o-rwx . # remove other-access to read, write, and execute this directory
git
introductionWe’ll use git in this class, and many other classes that follow. Git is a versatile tool that does many useful things; among them are
user.name
and user.email
Git is designed for collaboration, so it does not allow anonymous contributions. Hence, you have to tell it a name and email, either once per project or once for all projects on your computer. This information is visible only to other people who have access to your git project.
While inside the git project directory created by git clone
, run the following commands, using your name and email ID instead of those in the example:
git config user.name "Dana Wahoo"
git config user.email "mst3k@virginia.edu"
From anywhere, run the following commands, using your name and email ID instead of those in the example:
git config --global user.name "Dana Wahoo"
git config --global user.email "mst3k@virginia.edu"
Git will complain if you try to git commit
without having done this.
You’ll only need to do this once in this course, so we’ll only give a little explanation.
Create the git-managed project on the server, portal.cs.virginia.edu
. Use your user name, not mst3k
, and any name you want (we assume coa1-code
but you can change that)
ssh mst3k@portal.cs.virginia.edu
mkdir coa1-code.git
cd coa1-code.git
git init --bare
exit
Create a working copy of that project on the server
cd ~
git clone mst3k@portal.cs.virginia.edu:coa1-code.git
exit
Create your local working copy of that project
git clone mst3k@portal.cs.virginia.edu:coa1-code.git
cd coa1-code
If you have not set up a global username and email, you should then set those for this project (see user.name
and user.email
)
We may have you use projects we’ve made for you later in the semester, which uses step 2 of the above.
As a summary, the steps listed above that you should actually do are
ssh
your-computing-id@portal.cs.virginia.edu
mkdir coa1-code.git
cd coa1-code.git
git init --bare
cd ~
git clone
your-computing-id@portal.cs.virginia.edu:coa1-code.git
exit
git clone
your-computing-id@portal.cs.virginia.edu:coa1-code.git
cd coa1-code
git config user.name "
Your Full Name"
git config user.email "
your-computing-id@virginia.edu"
We expect the most common case will be you’ve created or modified a file on your laptop and want to try running it on the server. Let’s go through this step by step, assuming you start in Terminal/PowerShell in the directory of your project on your laptop
git add file1 file2 ...
Tell git
which files you want to have sent. If you want everything in the current directory sent, you can use git add .
.
If you created no new files, you can skip this step as described below.
git commit -m "I changed a few files"
Tell git
to update it’s internal copy of the files you’ve added and label this change “I changed a few files”. Using good descriptive labels becomes more important as project teams grow.
You can add and commit in one step if you have only modified (not added) files by using git commit -a -m "fixed typos"
git pull
git pull
before git push
.
git push
ssh mst3k@portal.cs.virginia.edu
cd coa1-code
git pull
Create a git project with a copy on your laptop and on the server, as described under “Creating a project” above
On your laptop, in the directory of this new project, create a file named lab01
that contains
I wrote this on my laptop! Hooray!
Don’t know how to make a file? See Lab 00 “CLI Editor”
then use commands from “Laptop → git → CS server” above to get it into git and onto the server’s version of the project. Then show the TAs you did so. One way to show this is to ssh
into the server, go to your project directory, and type the following
ls -l
pwd
ls -ld ~
git status
cat lab01
… then call over a TA to show them the results.
Since you already created a project in the last exercise,
cd
into your project directory
use an editor to make a file, as described in Lab 00.
use git to add
that file, commit
the addition, and push
it to the server
ssh
into the server
cd
into your project directory on the server
use git to pull
the changes you previously pushed
call over a TA to show you succeeded by showing them the output of
ls -l
pwd
ls -ld ~
git status
cat lab01
There are several tutorials you may find useful. Don’t feel that you have to do all of these (unless you want to and/or you need to still learn it), but doing at least one all the way through may help you feel more confident. You should probably do them on your own time, though, not during lab time.
Claude Shannon founded the field of information theory. A core fact in information theory is that there is a basic unit of information, called a “bit1” or a “bit of entropy.” Roughly speaking, a “bit” is an amount of information that is about as surprising as the result of a single coin flip. In the sentence “Hello, my name is Claude” the word “is” has low entropy; most of the time someone says “Hello, my name” the next word they say is “is,” so adding that word provides very little more information. On the other hand, the word “Claude” in thart same sentence has many bits of entropy; a huge number of words could reasonably follow “Hello, my name is” and any given one we pick is quite surprising.
In computers, we rarely encode things anywhere near as efficiently as its bits of entropy suggest. For example, most common encodings of strings use 8 bits per character. In this lab, you’ll replicate an experiment Claude Shannon published in 19502 to see just how inefficient that encoding is.
First, you’ll write a program in either Python or Java. Then, you’ll use that program to perform an experiment and reflect on the results.
You may either work alone or with a buddy in this lab. Buddy programming is where two people work side-by-side, each creating similar programs while talking together to help one another out. In well-running buddy programming each buddy is speaking about equally, describing what they are writing next or how they are testing what they have written. Buddy programming usually results in similarly-designed but non-identical programs.
If you use a buddy, you should sit next to your buddy and use the same programming language they use.
Your program should do the following:
Read a text file into a string in memory. You should be able to specify different file names each time you run the program.
Repeatedly
After some fixed number of iterations (20 might make sense), display
You got 14 out of 20 guesses correct!
”)Once your program seems to be working, try it on a few different texts. For example, you might try
Add a comment to the top of your code that includes at least the following:
Show a TA your working code. They may ask you some questions about how your code works and what you think of the results. For most students, this should happen in lab; if you have completed the lab exercise before lab occurs, you are welcome to do it in their office hours.