Welcome to CSC200 Lab 1



This is the first UNIX lab. You will go through the basics of the bash shell on a Debian Linux Dell Power Edge server, write and compile a simple C++ program. Please follow the directions below:



1. Place your XLiveCD in the drive and wait about 20 sec. for the cd to autoload. When prompted, click next and chose the 3 buttoned mouse option. Click next. You should see a teminal prompt.

2. Type ssh -X your_user_name@numbers and hit enter.

3. You may get a message about registry keys, type yes.

4. Enter you numbers password.

5. You are in your home directory(/home/<username>). List the contents of your directory by typing the command ls. This lists the files and folders in your directory. ls alone however does not list all of your directory's contents. Type ls -a. This displays your files as ls does, but also your "hidden" files (these are configuration files that begin with a period), the current directory (denoted .) and the directory above (denoted ..). Now type ls -al. This lists all files including hidden files as well as file sizes, permissions, ownership and date modified.

6. a. Next, create a new source file called first.cpp by typing: emacs first.cpp &

OR b. type: pico first.cpp


emacs will give you point and click ability!

7. In your emacs window, type:

// This is a sample introduction to C++ program
// It calculates you age in seconds
// Enjoy


//The following line lets us do output to the standard output


#include <iostream>  

using namespace std;

//Declare the needed stuff

const int MULTIPLIER = 365*24*60*60;   
int age_in_seconds, age_in_years;

string name;

int main()
{

  //Get information from the user

  cout << "Please enter your name: "; 
  cin >> name;

  cout << "Hi " << name << ", enter your age in years at your last birthday: ";
  cin >> age_in_years;

  //Perform the calcuation

  age_in_seconds = age_in_years*MULTIPLIER;  

  // Now output the results

  cout << "Your age in seconds is: " << age_in_seconds << endl;
  cout << "See how usefull C++ is?" << endl;

  return 0;
}

8. Now to complie. To complile your program, (and create a binary executable called first) type in the terminal window (not the emacs window): g++ -o first first.cpp

9. An 'ls' command should now show that you have a first.cpp source file and a first executable file in your directory. To run the executable type: ./first and hit enter.

10. After successful compilation and execution of your program, you can exit emacs by clicking File --> Exit Emacs.

10. To log off of numbers, type exit in your terminal window. Type exit again to end the local terminal session. Then right click the black X in the system tray and chose exit. You should now be able to remove the cd.