Unix Primer

1. Logging on to the system

It is HIGHLY RECOMMENDED the initial log on be in a full Linux session (ATS224 or 230), not ssh.
  1. Boot into Linux by selecting any key on machine start up and then selectingeither centOS option (1 or 2)
  2. At the log in screen click “Other”
  3. Enter your normal Windows username as follows:
    srunet\ ex: srunet\cxm1234
  4. Click Log On
  5. Enter you Windows password and click Log On

The first log in will be a little slow as all the directories are being built. If there is an authentication error try again and make sure everything is being entered correctly. If the error persists contact Chris Milliren.

Once connected to the local machine, you will have access to its file system and your user files that are stored on the obsidian Linux server.

To connect via SSH:

  1. Open Putty. In the host name field enter obsidian.sru.edu
  2. Confirm you want to store the SSH key if prompted to do so.
  3. Enter your Windows username without prepending srunet\ Press enter.
  4. Enter your Windows password and press enter.
  5. If this is your first log in you will see the following:
  6. If this is your initial log on, contact Chris Milliren after class to sweep the permissions. If this is not done their log in to the Linux desktop will have errors.

1.1. Logging out

To exit obsidian and return to the PC, type exit at the granite prompt. 1.2. Getting help in Unix The man command is useful to get more information about any command in Unix. For instance, to find out more about the cp command, you would type
man cp
More importantly, to get more information about the man command, use: man man
To get an introduction to the information available about C functions, use: man -s 3 intro
C system calls: man -s 2 intro
(There are seven sections in the standard man pages, -s specifies a particular section.)

The apropos command can help you find commands related to some keyword. For instance
apropos copy
would list all UNIX commands related to copying (including cp).

The man command uses the same kind of interface that the more command uses. It shows you one "page" of information at a time and waits for you to request more. Use the Enter key to step through the information, space to page through it and q to quit.
 

1.3 Editing your command line input

When you make a mistake typing a command it is nice to be able to correct it. Try typing a fake command like xyzzy and then using the backspace or delete key. Hopefully one of the two keys works. If not, or if you want to change it to the other key, you can set the terminal characteristics to match you preference:
stty erase ^h
where you press the key you want to be your backspace key instead of ^h (control-h). To erase an entire line of input, i.e., start over, type ^u (hold the control key and type a u).

More information about UNIX.

2. Editing

A number of editors are available in the UNIX environment for creating your programs. These include nano and vi, text-based editors that work when accessed through the terminal, and textedit, a windows-based editor that has full mouse capability but only works on the X-terminals.

Note that any C++ program file you create must end in .cc. C files end in c.

More information about nano.

3. Compiling and running

The UNIX C++ compiler is called g++. To compile your program, type that name followed by the name of your program, as in one of the following two commands:

g++ prog1.cc
gcc prog1.c

If your program has syntax errors, they will be printed to the screen. If you have more than one screen of errors, you can pipe the output to the more command to see them one screen at a time:

g++  prog1.cc  |&  more

If there are no syntax errors, the compiler will produce an executable file called a.out. To run the executable code, simply type in:

a.out

4. Printing

To print out a file (such as your program), use the following command:

lpr -PATS224 filename
OR
lpr -PATS230 filename

where filename is the file you wish to print,  and ATS224 indicates room 224 of the ATS building and ATS230 is room 230 of ATS

Your printout does not have an identifying "burst page" so be sure to include your name on anything that you print.

5. Submitting your programs

Along with a hardcopy, you may be asked to submit an electronic copy of your programs to me via the Linux dropbox on obsidian. To access this drop box, you must ssh into obsidian (See Direction 1).

cd ../cpsc207.0914
where 207 is your course number and 09 indicates Fall (01 indicates spring) and 14 is the year.

Then cd to your user id

Place the files into that folder as instructed for the assignment

You may want to (or be required to) submit a transcript of an interactive session.