CompOrg Fall 2005 Lab

Lab #1 - Unix account usage

9/7/05

This lab is basically to make sure that your Unix account is set up properly, that you have the necessary tools on your laptop to access your Linux account, that you can transfer files from your laptop to your Unix account and that you can edit, compile, and run a simple C program under Linux.

To receive credit for this lab you must do the following, and then ask a TA to check you off:

  1. Get an ssh client program installed on your laptop. Here are some options available:

    ssh clienthow to getnotes
    secureCRT Commercial program, but already installed on most RPI laptops. Fine for login sessions, but no support for secure file transfer.
    cygwin,ssh,scp Already installed on new RPI laptops, also available from cygwin.com Unix-like environment for Windows, ssh client is console based.
    client from ssh.org Non-commercial version ( Client for Workstations) available from www.ssh.org login session and windows drag-n-drop file transfer
    putty, pscp Available from http://www.chiark.greenend.org.uk/~sgtatham/putty/ putty is the ssh login client, pscp is secure file transfer (command line oriented).
    WinSCP Available from winscp.net WinSCP is secure file transfer only (no login support!)
  2. If you have received your CS account information (via email from labstaff@cs.rpi.edu), you can log into ashley.cs.rpi.edu or monica.cs.rpi.edu.

  3. If you have not yet received your CS account information, you can log into Dave's office machine (running Linux). The machine name and account info will be given out in lab.

    NOTE: If you are using Dave's machine, you must create a driectory for your use (otherwise it is possible we will have multiple students working in the same directory, which will cause chaos as we all try to work on the same files at the same time).

  4. Use your ssh client to log in (Dave will demonstrate in lab).

  5. Grab a copy of the C program showbytes.c and save this to your hard disk (right click and "save as"). Now transfer this file to your Unix account using whatever file transfer software you got in step 1.

  6. Use the Unix "ls" command to verify that you have the file, you can use the command "more showbytes.c" to look at the contents of the file.

  7. Compile and run the program:

    > gcc -o showbytes showbytes.c
    > ./showbytes
    
  8. Use an editor (suggestions below) to change the program so that it displays the value of the integer 17 (instead of the integer 1).

  9. Add the variable s to main:

    char *s = "Hello";
    

    Change main so that it displays the value of the pointer s.

    Raise your hand or yell for a TA and get checked off!


Unix Text Editors

There are a number of popular text editors used in console mode by Unix programmers, here is some information on how to start these up and how to get more information:

emacs

emacs is a very powerful editor written in a dialect of lisp that allows you to easily add new commands or alter existing commands ("easily" if you know lisp...). To start the editor just type "emacs" (or "emacs showbytes.c" to start editing the showbytes source code). Within emacs you can start up a tutorial by pressing Ctrl-h and then t.

Here are some useful emacs links:

vi (vim)

vi is another popular text editor, although very different from emacs. vim is an improved version of vi, and under many flavors of Linux vi is really vim.

To start up vi just type the command "vi showbytes.c". You can get help by typing ":help" when in vi. You can run a vi tutorial by issuing the command "vimtutor" from the unix command line.

Here are some useful vi/vim links:

pico

pico is a very simple, easy to use editor (this is probably the easiest one to get started with). Just enter "pico showbytes.c" at the Unix command line - pico commands will be displayed at the bottom of the screen.


Unix Commands

For this lab you don't need to know many Unix commands, but below are some references that can help you get started: