Name: __________________________

 

Lab 1 Introduction to UNIX and C

 

This first lab is meant to be an introduction to computer environments we will be using this term.  You must have a Pitt ID to complete this lab. 

 

NOTE: Text in UNIX is case-sensitive.  CS132 is different from cs132 is different from Cs132.  All filenames of concern in this lab are lowercase. 

 

Please follow the instructions as listed in this document.

 

 

Here are a few common UNIX commands:

 

 

Part I

 

1)      To login to the computers, you will need to use an SSH client.  The SSH client that we will be using is F-Secure SSH Client

·        located under Programs in the Start Menu

2)      When you login first, you are placed in your home directory. The command

ls

 

will LiSt all of the files and directories there. The one we are most concerned with is the private directory. It is special in that only you can access files inside this directory.  It will keep your work safe from other people.

 

3)  Let’s move into the private directory so we can work there:

 

cd private

 

Changes Directory to the private directory

 

4)  For this class, we’ll keep all of our files organized into a cs132 directory. Make it by typing:

 

mkdir cs132

 

If you want to double check that it worked, type ls to list.

 

5)  We now want to move into the cs132 directory to do our actual work.

 

cd cs132

 

 

Part II.

 

1)  While still in the cs132 directory type:

 

pico lab1.c

 

pico is a very simple text editor, a lot like Notepad on windows. It is what we will be writing our programs in this term.

 

2)  Type the following text in exactly as it is shown:

 

#include <stdio.h>

 

int main() {

     printf(“Hello World!\n”);

     return 0;

}

 

3) Save the file by hitting Ctrl + O and then enter. Exit pico by typing Ctrl + X. At the bottom of the pico window, it shows what keys do special things. The ^ means to hold Ctrl while pressing the key

 

4)  Back at the prompt type:

 

gcc –o lab1 lab1.c

 

which will make our program. A file named lab1 will be in the directory if we type ls

 

5)  Run it by typing:

 

./lab1

 

Show the output to the TA and you are done with the first lab.

 


Helpful Hints

 

 

cd private

 

cd cs132