THIS IS NOT THE LAB FOR THE CURRENT QUARTER!!!!
If you are in one of Conrad's CS16 sections, please visit foo.cs.ucsb.edu/16wiki for information on the current quarter of CS16.
PDF version (steps 1-4 and troubleshooting for those steps only)
By the time you have completed this lab, you should be able to
That's a bit general, so let's get more specific...
This assignment is designed to make sure you are comfortable working in the Cooper Lab/CSIL environment and know how to submit your work. So, this lab is mostly about mechanics, not concepts. As a result, this assignment is not particularly intellectually challenging. I hope that will not be the case in future labs!
Ideally, before this lab begins, you will have been instructed to visit the link below, and create your "College of Engineering" computer account:
If you already did that, then wonderful! Proceed to step 1.
Otherwise, if you've arrived at your lab session without having already done this:
If it doesn't work: troubleshooting information is available at:
http://www.cs.ucsb.edu/~pconrad/cs16/10S/labs/lab00/trouble.html
Note that if you are not enrolled in the course on GOLD, you normally cannot get a College of Engineering account—if there is some problem with your GOLD registration, but you still need to start the work in the course speak with your instructor about this.
We assume that most (if not all) of you are already in Cooper Lab at this step.
If you are making up this lab assignment outside your regularly scheduled lab time (because you added the course late for example), then you should go to CSIL to do it.
When you sit down at a computer in Cooper lab (or CSIL), you'll see a prompt that asks you for your username. Enter the username that you created for your College of Engineering computer account. This is probably the same as your UCSBNetID (your umail account), unless you specified something different when you created your account.
When you are asked for a password, enter the password you chose for your College of Engineering account (which is not necessarily the same as your umail password.)
Don't worry if nothing appears on the screen while you are typing your password.
You should find that your username and password are accepted, and you get a "desktop" that looks similar to the Windows or Mac OS desktop. In fact, what you get is neither—the systems in Cooper and CSIL use "Linux", which is a different operating system.
In the rest of this lab, we'll walk you through a few of the basics of using this desktop. Most things, though will likely be pretty familiar to you, because they aren't that different from Windows or Mac.
Troubleshooting:If your username/password don't work - see troubleshooting step 2:
The web address is: http://www.cs.ucsb.edu/~pconrad/cs16/10S/labs/lab00/trouble.html
You should now be able to find these instructions online at this link:
http://www.cs.ucsb.edu/~pconrad/cs16/10S/labs/lab00
Note that the ~ symbol (called "tilde", or "squiggle") in front of pconrad is located at the upper left hand corner of the keyboard—and it requires a shift, otherwise you'll get ` which is called the "backtick".
If you received a paper copy of these instructions, this is where the printed copy will end—to save paper, the rest of the instructions can be found online.
On the Linux systems, there a lot of things we can do with pointing and clicking with the mouse, just like on Windows or Mac. But there are also many things we can only do with the command line, or can do more easily with the command line.
So, one of the first steps will often be to bring up a "Terminal Window", which is the Linux "command line".
Here's how:
Here's what it should look like (click on a thumbnail to bring up a bigger image)
Selecting the menu option | Result |
![]() |
![]() |
If you are working in the Cooper lab, before we go any further, we need to make sure that your username/password also work on the CSIL computers.
If you are working in CSIL (e.g. because you missed the first week's lab and are making it up by working in CSIL), we need to make sure your username/password also work on the Cooper computers.
This is just a "check" to see if there are any problems with your account.
We will try your username/password over the internet using a program called ssh, which stands for secure shell.
In the Terminal Window that you brought up in the previous step, enter the following command:
ssh csil.cs.ucsb.edu
When you type this at the Unix command line, you may see something like this:
-bash-3.00$ ssh csil.cs.ucsb.edu The authenticity of host 'csil.cs.ucsb.edu (128.111.43.14)' can't be established. RSA key fingerprint is 90:ab:6a:31:0b:81:62:25:9b:11:50:05:18:d3:1a:b5. Are you sure you want to continue connecting (yes/no)?
Answer the question by typing yes, and pressing "enter" (or "return")
Then, you'll be prompted for your password.
Don't worry if nothing appears on the screen while you are typing your password.
If it worked, here's what you'll see something like this:
pconrad@csil.cs.ucsb.edu's password: Last login: Thu Aug 6 08:09:04 2009 from linux32.engr.ucsb.edu
Welcome to Computer Science's Remote Access server -- csil.cs.ucsb.edu
You may run your graphically intensive programs on specific workstations in CSIL.
-bash-3.2$
At this point, we know that you can connect to CSIL. We'll need to do again later, at the step where you are ready to submit your work for grading. But for now, we can exit from our session on CSIL by typing the word exit, like this:
-bash-3.2$ exit logout Connection to csil.cs.ucsb.edu closed. -bash-3.2$
If you are ever not sure whether you are logged in to CSIL or not, you can type the command hostname at the command prompt. If you are logged into CSIL, it will look like this:
-bash-3.00$ hostname csil.cs.ucsb.edu -bash-3.00$
If you just have a plain terminal window in Cooper, it will look like this:
-bash-3.00$ hostname _____.engr.ucsb.edu -bash-3.00$
If you are working in CSIL (e.g. because you missed the first week's lab and are making it up by working in CSIL), we need to make sure your username/password also work on the Cooper computers.
The instructions are exactly the same as those for Cooper, except the command you use is this one:
ssh linux.engr.ucsb.edu
Please follow the instructions above, and make sure that everything works properly. If you have any difficulties, please ask your instructor or TAs office hours for assistance, either during your scheduled lab time, or during office hours.
Office hours for CS16 in Spring 2010 can be found here:
http://www.cs.ucsb.edu/~pconrad/cs16/10S/ofchrs
At the command prompt, we are going to type several commands to create folders (called "directories") on Linux in which you can store your programs. The commands are shown in the box below—but first, a little explanation.
Each of the cd commands shown below is a command to "change directory"—that is to move into a different folder on the hard drive.
Each of the mkdir commands "makes a new directory" (i.e. a new folder).
Each of the pwd commands "prints the working directory", i.e. it tells you where you are on the hard drive.
At the command prompt, type each of these commands. What you type is shown in bold. You should get back exactly the output shown, (except that the part in italics may be different—each user will have something different show up there.)
-bash-3.00$ cd -bash-3.00$ pwd /cs/student/yourusername -bash-3.00$ mkdir cs16 -bash-3.00$ cd cs16 -bash-3.00$ pwd /cs/student/yourusername/cs16 -bash-3.00$ mkdir lab00 -bash-3.00$ cd lab00 -bash-3.00$ pwd /cs/student/yourusername/cs16/lab00 -bash-3.00$ cd -bash-3.00$ pwd /cs/student/yourusername
To see if it worked, you can use the file manager on the desktop. Drag any windows that might be covering up the little icon that says "home" on your desktop—it should be near the upper left hand corner of the screen, and looks like this:
When you double click on this, it will bring up your home directory. You should see inside a folder called cs16. If you double click on that, you should see inside of it, a folder called lab00
Note that you could also use mouse clicks and menu options to create these folders, instead of the command line. If you have trouble with the command line, then for today, its ok to do it that way.
Eventually, though, we want you to learn some of the Unix commands also—the reasons its important to know both will become more clear as you move deeper into the study of programming and Computer Science.
Next we want to copy a file called firstCProgram.c into the directory that we'll refer to as ~/cs16/lab00.
Remember that "folder" and "directory" are interchangeable words.
As review, what does ~/cs16/lab00 mean?
Open a terminal window, and use the cd command to navigate to the ~/cs16/lab00 directory as you did in step 7. When you type pwd, you should see that you are in ~/cs16/lab00.
The type this command at the Unix prompt. This says you want to copy a file from my directory into your ~/cs16/lab00 directory.
cp ~pconrad/public_html/cs16/10S/labs/lab00/firstCProgram.c ~/cs16/lab00
If you get an error message, see "Troubleshooting" below before asking the TA for help.
If it works, then you should be able to type the ls
command (that's the lowercase letter L as in "list" followed by the letter "s") to see that you now have a file called firstCProgram.c
in your directory:
-bash-3.2$ cp ~pconrad/public_html/cs16/10S/labs/lab00/firstCProgram.c ~/cs16/lab00
-bash-3.2$ ls
firstCProgram.c
-bash-3.2$
Troubleshooting cp: If you have trouble, check this:
~
and the word pconrad
, ~
and the cs16
.
pconrad
.cs16
in your own
user account.firstCProgram
, with the C
and the P
capitalized.Assuming you successfully completed Step 8, and are now in the
~/cs16/lab00
directory and it contains the file firstCProgram.c
, we
are ready to run the program. Before you do, type the pwd
and ls
commands (print working directory, and list
files). The result should look like this—except you'll see your
home directory listed instead of /cs/faculty/pconrad
.
-bash-3.2$ pwd
/cs/faculty/pconrad/cs16/lab00
-bash-3.2$ ls
firstCProgram.c
-bash-3.2$
If that's ok, then we are ready for the next step. To prepare to run the program, we can use the following command:
make firstCProgram
Try typing that now. It should look like this:
-bash-3.2$ make firstCProgram cc firstCProgram.c -o firstCProgram
-bash-3.2$
If you get something else, see "Troubleshooting" below before asking the TA for help.
If it worked, then try typing ls. You should see that you now have another file in your account, called firstCProgram. This is the machine language version of your program. To run it, you type the following at the Unix prompt:
./firstCProgram
Here's an example of what that would look like:
-bash-3.2$ ./firstCProgram Please enter a fahrenheit temperature: 68 68.000000 degrees F is 20.000000 degrees C More conversions? Enter 0 for no, 1 for yes: 0 Goodbye! -bash-3.2$
Troubleshooting make: If something goes wrong, check these things
-bash-3.2$ make firstProgram make: *** No rule to make target `firstProgram'. Stop. -bash-3.2$
A special note for lab00
Normally, before submitting an assignment in this class you'd have to do something more than just download a file and run it! But since the first lab is occurring before the first lecture this quarter, we are keeping things fairly simple.
So this lab isn't worth very many points—it is mainly here to make sure that you are comfortable with all the mechanics of working in the lab. So, this week, you get 40 points for just being able to download a file, and submit it properly. By next week, you'll be writing your own C programs to submit, and you'll have to work and think a bit harder to earn the points.
How to submit your assignment
To submit your assignment, you need to bring up a terminal window on CSIL.
To start this process, we use a few steps that we practiced earlier:
-bash-3.00$ cd -bash-3.00$ pwd /cs/student/yourusername -bash-3.00$ cd cs16 -bash-3.00$ pwd /cs/student/yourusername/cs16 -bash-3.00$
Type the following at the prompt:
turnin lab00@cs16 lab00
You should be asked if you want to turn in this program. Respond "yes", and then you should get a message indicating that your efforts were successful!
Due Date:You should try to complete this assignment by the end of your first discussion section, i.e. before 9:50am, 10:50am, 11:50am or 12:50pm on Friday 04/02/2010 (depending on which section you are enrolled in.)
You may submit it without late penalty through 5pm on 04/09/2010.
After that, there is a 10 point penalty.
The absolute latest we will accept this lab is 5pm Friday 04/16/2010, and this is only an accommodation for students that may add the class late. If it is not submitted via turnin prior to that date, you will receive a zero.
Therefore, you are strongly encouraged to complete it as soon as possible.
(Note: the due dates for lab00 and lab01 are exactly the same—though they may be submitted separately. Submit lab00 as soon as you finish with it—then immediately start work on lab01.)
By Phillip Conrad, with additional material by Michael Costanzo. Copyright 2010, CS Dept, UC Santa Barbara. Permission to copy for non-commercial, non-profit, educational purposes granted, provided appropriate credit is given; all other rights reserved.