By the time you have completed this lab orientation part of Pre-lab 1, you should be able to
If you don't already have one, you must create a College of Engineering (CoE) account to use for labs and programming assignments. You must be enrolled in this course in GOLD to do so. If you already have an account, then skip to step 1.
Finding CSIL: CSIL is located in Harold Frank Hall (HFH). You enter from an outside door. To locate CSIL, find the "main front entrance" to Harold Frank Hall, on the side of the building that faces the ocean. Stand outside the double glass doors, with your back to the building, facing the ocean. The entrance to CSIL is now on your left.
The computers in CSIL are just like the computers in the Cooper Lab, where your weekly Lab sessions (discussion sections) will be held. FYI: the Cooper Lab is located in the Engineering Science Building, room ESB 1003. ESB is located at the corner of campus closest to the airport, furthest away from Isla Vista. ESB is divided into two parts, with a pedestrian bridge overhead. ESB 1003 is in the part of the building closest to the bike path. The door to ESB 1003 is on the ground floor, at the corner that faces the airport. But the Cooper Lab is only available during your weekly scheduled discussion section—it is not open for your use at other times.
By the way, the effective steps of this assignment can be accomplished by connecting to CSIL
csil.cs.ucsb.edu but if you don't already know how to connect remotely
to a Linux system, then we prefer that you visit CSIL in person to do this work. Eventually you
probably will want to connect remotely though, and at that time we refer you to Professor Conrad's
separate advice for connecting to CSIL from
The remaining instructions assume you are at CSIL working on one of the computers there.
When you sit down at a computer in CSIL (or Cooper lab), 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 assignment, 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.
If you want to view these instructions at CSIL, a web browser is available there.
Use your mouse and find the Applications Menu at the top left of the screen.
Select Internet, then Firefox:
On the Linux systems, we can do a lot of things by pointing and clicking with the mouse, just like on Windows or Mac. But there are also many things we can only do (or 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 what it should look like (click on a thumbnail to bring up a bigger image)
|Selecting the menu option||Result|
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 the output shown (except that the part in italics will be different for each user).
-bash-4.1$ cd -bash-4.1$ pwd /cs/student/yourusername -bash-4.1$ mkdir cs16 -bash-4.1$ cd cs16 -bash-4.1$ pwd /cs/student/yourusername/cs16 -bash-4.1$ mkdir lab00 -bash-4.1$ cd lab00 -bash-4.1$ pwd /cs/student/yourusername/cs16/lab00 -bash-4.1$ cd -bash-4.1$ 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 icon that says "Home" on your desktop—it should be near the upper left hand corner of the screen:
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 it's 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, here is what
Open a terminal window, and use the cd command to navigate to the ~/cs16/lab00 directory as you did in step 6. When you type pwd, you should see that you are in ~/cs16/lab00.
Then type the following command at the Unix prompt. This says you want to copy a file from my directory into your ~/cs16/lab00 directory.
cp ~kyledewey/cs16/lab00/firstCProgram.c ~/cs16/lab00If you get an error message, see "Troubleshooting cp" below before asking anybody 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-4.1$ cp ~kyledewey/cs16/lab00/firstCProgram.c ~/cs16/lab00 -bash-4.1$ ls firstCProgram.c -bash-4.1$
Troubleshooting cp: If you have trouble, check this:
Assuming you successfully completed Step 5, 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
ls commands (print working directory, and list files). The
result should look like this—except you'll see your home directory listed instead of
-bash-4.1$ pwd /cs/faculty/pconrad/cs16/lab00
If that's ok, then we are ready for the next step. To prepare to run the program, we can use the following command:
Try typing that now. It should look like this:
-bash-4.1$ make firstCProgram cc firstCProgram.c -o firstCProgram
If you get something else, see "Troubleshooting make" 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:
./firstCProgramHere's an example of what that would look like:
-bash-4.1$ ./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-4.1$
Troubleshooting make: If something goes wrong, check these things
-bash-4.1$ make firstProgram make: *** No rule to make target `firstProgram'. Stop. -bash-4.1$
You will have to use the UCSB Computer Science program named
turnin to turn in
your programming projects and possibly other assignments for this class. In fact, this will be
true for most of your CS classes from now on. So you might as well
learn how to use it now, by turning in a copy of the sample program and its executable version.
Normally we will just want you to turn in the source code (.c) file, but this time you will
turn in the whole lab00 directory.
In a terminal window, navigate to your cs16 directory:
-bash-4.1$ cd -bash-4.1$ pwd /cs/student/yourusername -bash-4.1$ cd cs16 -bash-4.1$ pwd /cs/student/yourusername/cs16 -bash-4.1$
When you are in inside your cs16 directory, you are ready for the turnin step.
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!
You've completed the required tasks of this lab orientation assignment, but we suggest you stay (or come back) to do some "Extra Learning" tasks below. At the very least you should learn how to use emacs (or vi or another editor program) to answer some of the Pre-lab 1 questions, and especially to prepare for Lab 1.
Log out of your account before leaving the lab.
- If you already turned in the required files, then how about creating a new file in the ~/cs16/lab00 directory using emacs (or another of the editors available at CSIL if you prefer). This file's contents are not important. What is important is that you learn to use an editor. Here is some emacs help to get you started.
- Bring up a terminal window again (as in Step 3 above), and learn about some Linux commands.
- First have some fun. Try
fortunea few times, for instance. Then try
cal. Both of these programs have options, and you can find out about options of most Linux commands with the
manprogram. Try typing
man cal, for example. Can you figure out how to show the calendar for 1752, and then do you notice anything weird about it?
manto look up some other commands you know, like
lsand so on.
- Do you know how to protect your files from other users? Try
man chmodto get some idea.
- Play with more Linux commands. Here is an extensive command reference for guidance.
- Watch the video at http://www.cs.ucsb.edu/~mikec/cs8/misc/pairvideo.html (or http://www.realsearchgroup.org/pairlearning/) about pair programming. Maybe you saw this 10-minute video before, but watch it again to prepare for future lab work.
- Some questions usually included with the first homework were not assigned this quarter, because of the unusual scheduling of the first lab before the first lecture. However, these questions are still important. You can find the answers in your textbook. Here are some basic questions similar to the usual set. Write the answers in your notes to study later for exams.
Copyright 2009, Phillip T. Conrad, 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. Adapted by Kyle Dewey from Michael Costanzo for this quarter.