CompOrg Spring 2004 Lab

Lab #1 - Linux account setup and usage

1/21/2004

This lab is basically to make sure that your Linux 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 Linux 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 Evaluation version 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).
  2. Get your Linux account information from a TA or Dave (you basically need to get your password - the login name is the same as your RCS login name).

  3. Use your ssh client to log in to monte.cs.rpi.edu using your login name and password.

  4. Type in the Unix command passwd and change your password to something you will remember.

  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 Lunix account on monte.cs.rpi.edu 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 (on monte.cs.rpi.edu) 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: