CSCI 180/181 Spring 2008, Lab 1

Objectives

1. Setting up your account on cerebro

cerebro.cs.xu.edu is the computer science server. You can use it for file storage, for programming, for email, for webpages, and all sorts of other good things. In this course the main use will be to use it for handing in your assignments, though you are welcome to use it for other purposes as well.

This account is essentially permanent. Your email address is loginName@cs.xu.edu where loginName is the name you use to login. (You can read mail from cerebro or have it forwarded to another account.)

How to connect cerebro

Campus PCs

All computing labs on campus should have a collection of programs called "cygwin" installed. It is in the Departmental Software for Mathematics and Computer Science (right by the BlueJ program).

In the terminal window you see come up, execute a program called secure shell to log into cerebro. You execute it by typing
ssh -Y login@cerebro.cs.xu.edu
where login is your login name on cerebro. You will be prompted for a password. When you get connected you will have established an encrypted connection to cerebro.

PCs may also have other options for connecting: CRT 3.4 is on the lab machines as well. If you select "Quick Connect" under the file menu and enter cerebro.cs.xu.edu as the host/server name you will be able to connect (you'll be prompted for both login name and password). CRT is not encrypted and our preference is the cygwin connection.

Macintosh users

Best thing to do is consult mikeyg. I think that Leopard OS has what you need already, but he will know for sure.

2. Simple Commands in Unix

  1. Changing your password: You can change your password using passwd at the terminal prompt on cerebro.

    Change your password now.

  2. Cerebro and most unix machines include a very simple text file editor called pico. It includes a menu at the bottom explaining how to use it. (We will see other, more programming-oriented editors for unix later, but this is a handy editor for beginners.)

    Use pico to create a file. Enter your name and favorite tree. Save the file as firstfile.txt. Exit pico.

  3. Useful commands for exploring, moving, copying files

    Unix uses a tree-structured file system. Files are placed in directories. When you login, you start in your home directory. You can create files in this directory, or make sub-directories and place files in those.

    In every directory there are two special subdirectories. The '..' directory is the parent directory of the current directory. The '.' directory is the directory you are currently in.

    1. To view the names of the files in your current directory, use the ls command. You should see the files "firstfile.txt" listed.

    2. viewing the contents of a text file
      less and more are "pager" utilities for viewing text files. For example,
      type less firstfile.txt at the prompt.

      You should see the contents of firstfile.txt on the screen.

      If the file takes more than one screen to display, you can use the spacebar or down-arrow to move down in the file.

      To leave less, type 'q'.

    3. creating a directory
      1. At the prompt, type
        mkdir csci180

      2. Now do
        ls
        You should see the name csci180 listed in your directory, along with firstfile.txt. You have just created a subdirectory.

    4. Changing directories
      cd directory name moves you to the specified directory. If you are in a sub-directory and want to move up one directory, use cd ...

      1. type cd csci180 at the prompt.
      2. now do an ls, you should see no files.
      3. now type cd .. and then do an ls. You are now back in your home directory and should see firstfile.txt and csci180.
      4. cd back to csci180
      5. now make a directory called "lab1"
      6. do an ls, you should see lab1 listed in this directory
      7. cd lab1
      8. now type cd alone on a line.
      9. type ls, you should see firstfile.txt and csci180. If you type cd alone on a line, you are always returned to your home directory.
      10. now do cd ~ejohnson
        do an ls and you should see a bunch of files you haven't seen before -- you are in my directory.
      11. now do cd ~loginName where loginName is your login.
        Do an ls
        You should see that ~loginName is always the home directory of the person with that loginName.

    5. copying files
      cp originalfile newfile copies a file.

      1. type cp firstfile.txt secondfile.txt
      2. Now do an ls, you should see a new file called secondfile.txt
      3. Use less to view the file, you should see that it is the same as firstfile.txt
      4. Now do cp firstfile.txt csci180/lab1/
        You have just copied firstfile.txt into the lab1 subdirectory.
      5. cd csci180/lab1 and then do an ls to verify that firstfile.txt has been copied to this directory.
      6. Now do a cd to get back to your home directory.
      7. you can list the files in a subdirectory directly by doing ls csci180/lab1

    6. moving/renaming files mv originalname newname can be used to both rename and move a file (mv stands for move, obviously).

      1. type mv firstfile.txt first.txt
        Now do an ls, you should see that you no longer have a file called firstfile.txt in your directory, but you do have a file called first.txt

      2. Now type mv first.txt csci180/
      3. Do an ls. You should see that first.txt is no longer in this directory.
      4. change directory to csci180 and list the files in the directory. You should see first.txt and lab1 in this directory.

    7. removing files
      rm filename removes the file.
      1. type cd to get back to your home directory
      2. type rm secondfile.txt
      3. type ls
        You should see that secondfile.txt is no longer in the directory, you have removed it.

      There are two important things about rm:

      • rm does not remove directories.
      • rm does not ask for verification to see if you really mean to delete the file, if you want it to do that, use rm -i

    8. removing directories
      rmdir directory removes a directory; the directory must be empty.
      1. cd into csci180/lab1
      2. do an ls to see if there are files in the directory (firstfile.txt should be there)
      3. do a rm of each file in the directory.
      4. Now, type cd .. to move up one directory.
      5. do an ls to see the files, you should see lab1 in the directory.
      6. type rmdir lab1
        do an ls to verify you have removed the directory.
  4. Create the lab1 directory again by doing:
    mkdir lab1
    You'll need it for a later part of this lab.

3. mail

A nice mail program called pine is on cerebro. It has a simple interface with a menu and help functions to read your email.

Mail on cerebro is also accessible remotely using typical mail clients, but if you would rather have your mail forwarded from cerebro to wherever you currently have an account, you can create a .forward file. The .forward file is a file named .forward which contains only a single line, the address where your mail should be sent, e.g.

foobar@hotmail.com

If you will be using forwarding, create your .forward file now (using pico). Then send me email using pine and tell me whether or not you are using email forwarding.

4. Moving your bluej code

If you are using a PC, the easiest way to move files up to cerebro is the WS FTP program.
  1. Under the Start and Programs menus, you should see a "WS FTP" menu item; select the WS FTP program from within this item.

  2. The left side is your local machine, the right side will be your cerebro account.

  3. Choose connect to remote machine and enter cerebro.cs.xu.edu; give your login and password.

  4. When connected you should see the contents of your directory in the right side window.

  5. To transfer files, simply move into the appropriate directories in both the left and right windows, then select the file and click on the arrow that moves it from one window to the next (downloading from cerebro will mean a click on the left-pointing arrow).

Try it now by transfering the Shapes project (which you will see as a folder called shapesin FTP) from your network space into your csci180/lab1 directory on cerebro. You can transfer the entire director yat once by highlighting the directory name and using the arrow to transfer.

5. Using handin

Once you have your files stored on cerebro, you can hand them in electronically. The command is

handin course# assignmentName files

where

As an example, suppose you wanted to handin the files in csci180/lab1/shapes/ for this lab. You would execute the following command:

handin 180 lab1 ~/csci180/lab1/shapes/*
(since * is the wildcard meaning all files in that directory).

When you run handin you should get a message telling you your files were copied and (hopefully) that your assignment was on time.

Try it now.

you can use handin frequently, to handin partial solutions to assignments. It only replaces files with duplicate names (i.e. if you need to handin foo and bar you can handin foo and then handin bar).

6. Some BlueJ

Complete the following exercises.
  1. Exercise 1.13
  2. Exercise 1.14
  3. Exercise 1.15 Choose either sun for your sunset!
handin your modified Picture class (so Picture.java) as part of lab1. To do this, you will need to transfer Picture.java to cerebro and then use handin to hand it in.


Gary Lewandowski
Last modified: Wed Jan 14 15:17:41 EST 2004