Unix Lab 1

CS 245

Sept. 20, 2004

  1. Login to a Windows workstation and start the SSH Secure Shell Client software. Click the Quick Connect button and enter the Host Name (phoenix.goucher.edu) and User Name information requested for the dialog box which pops up. Click the Connect button and then enter your password into the next dialog box.

    Unix is case sensitive --- be careful when entering username and password!

    A brief bit of documentation on SSH Secure Shell is available here
    (http://phoenix.goucher.edu/~kelliher/SSH/). In particular, you can download a copy of the software for educational use.

  2. You should now be sitting at a command line prompt on phoenix:
    >
    
    (or something similar). You type a command and then press Enter to run it. You can edit a command before you run it by using the arrow keys to navigate the command line.

  3. Check to see if you have an emacs initialization file (.emacs) in your home directory:
    ls -l .emacs
    
    If not, Copy this file from a directory under my home directory to your home directory:
    cp ~kelliher/pub/.emacs .
    

  4. Run the emacs editor on your .cshrc file in your home directory. First, try it this way:
    emacs .cshrc
    
    If that doesn't work, you'll have to use the full path this first time:
    /usr/local/bin/emacs .cshrc
    
    (You are in your home directory when you first login).

    Find the line which begins

    set path=
    
    and edit it so that it appears like this:
    set path=(/opt/sfw/bin /usr/local/bin /usr/bin /usr/ccs/bin \
    /usr/openwin/bin  /usr/ucb)
    
    Make sure you type this exactly as you see it here. There should be nothing following the \ on the first line, or, for that matter, following the \ on the set prompt= line below.

    Add these lines to the end of the file:

    umask 077
    set prompt="%m:%~\
    %% "
    alias .     logout
    alias ?     apropos
    alias cp cp -i
    alias grep  grep -i
    alias h     history 25
    alias ls ls -F
    alias ll ls -l
    alias mv mv -i
    alias rm rm -i
    
    Save the file (type C-x C-s) and find your .login file (type C-x C-f .login). Add these lines to the end of the file:
    setenv   BLOCKSIZE 1K
    setenv   LESS  "-ceiMswx3"
    setenv   PAGER less
    setenv PRINTER hs149ps
    
    Save the file (type C-x C-s) and exit from emacs (type C-x C-c).

  5. This is important to do now so that the two new environment variables are read properly: log out (run the logout command) then log back in.

    Did you notice that your command line prompt has changed? It now shows the machine name and the directory you're in (~ is the abbreviation for your home directory).

    After logging back in, you can run emacs just by typing emacs, if you weren't able to before.

  6. If you're using the system for the first time, you should change your password. Before selecting a password, read the file /usr/local/info/password for advice on choosing a good password:
    less /usr/local/info/password
    
    (The shell you're using has file completion. Type the command above up to /usr/loc and press the Tab key. The rest of the path component --- al --- will be filled in for you. This saves typing when you have long filenames)

    Within less, use the space bar and b key to move down or up, respectively, a page. Type q to quit less.

  7. Use the passwd command to change your password. Assuming that your Goucher network password is a good password, use that one. If it isn't, don't use it. I run a password cracking program every so often, so if you choose a weak password I'll find out and you'll have to change it.

  8. Using emacs, create a file named name containing your name. Print the file:
    lpr name
    
    The file should be printed on the printer in HS 149. If you ever want to print to the printer in the X Lab, you must use the -P switch:
    lpr -Phs123ps <filename>
    
    Remove the file you just created:
    rm name
    
    Unlike Windows, once you remove a file in Unix, it is gone for good. So be careful!
  9. Change directories to /etc:
    cd /etc
    
    You can verify that you're where you think you are by running the print working directory command: pwd.

    Using the ls command, list the files in /etc. Too many to fit on a single screen? Pipe the output to the paging program:

    ls | less
    
    Repeat again using the -l option to ls What's the difference?

  10. Change directories back to your home directory (run cd without an argument). List the files in your home directory. Try again using the -a option. What's the difference? Read the man page for ls to read about these two options and find what other options are available:
    man ls
    

  11. Using the mkdir command, create a sub-directory within your home directory for this lab: unix1. It is a good idea to create a new directory each time you start a new assignment or project, so that you don't clutter up your home directory. Using sub-directories for your assignments also helps keep others out of your files.

  12. cd to ~kelliher/pub/cs245 and use cp to copy Prog.java to your unix1 directory:
    cp Prog.java ~/unix1
    

  13. Change directories back to you unix1 directory and compile the program:
    javac Prog.java
    

  14. Run the program:
    java Prog
    

  15. If there is time, re-write the program so that it prints the first 10 numbers in the Fibonacci sequence. is 0 and is 1. The recurrence equation for succeeding elements of the sequence is .

  16. When you're finished, logout from phoenix.



Thomas P. Kelliher
Fri Sep 17 11:12:36 EDT 2004
Tom Kelliher