CSCI 180/181 Spring 2008, Lab 1
Objectives
- Cerebro
- set up your account on cerebro, the computer science server
- learning how to connect to your cerebro account
- A simple editor on cerebro
- learn simple commands to make directories and copy files on
cerebro.
- learning how to move bluej projects to cerebro
- learning how to use the handin program on cerebro
- email
- A bit more BlueJ practice with shapes.
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
- Changing your password: You can change your password using
passwd at the terminal prompt on cerebro.
Change your password now.
- 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.
- 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.
- To view the names of the files in your current
directory, use the ls command.
You should see the files "firstfile.txt" listed.
- 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'.
- creating a directory
- At the prompt, type
mkdir csci180
- Now do
ls
You should see the name csci180 listed in your directory, along
with firstfile.txt. You have just created a
subdirectory.
- 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 ...
- type cd csci180 at the prompt.
- now do an ls, you should see no files.
- now type cd .. and then do an ls. You are
now back in your home directory and should see firstfile.txt and csci180.
- cd back to csci180
- now make a directory called "lab1"
- do an ls, you should see lab1 listed in this directory
- cd lab1
- now type cd alone on a line.
- 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.
- 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.
- 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.
- copying files
cp originalfile newfile copies a file.
- type cp firstfile.txt secondfile.txt
- Now do an ls, you should see a new file called secondfile.txt
- Use less to view the file, you should see that it is the
same as firstfile.txt
- Now do cp firstfile.txt csci180/lab1/
You have just copied firstfile.txt into the lab1 subdirectory.
- cd csci180/lab1 and then do an ls to verify that
firstfile.txt has been copied to this directory.
- Now do a cd to get back to your home directory.
- you can list the files in a subdirectory directly by doing
ls csci180/lab1
- moving/renaming files
mv originalname newname can be used to
both rename and move a file (mv stands for move, obviously).
- 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
- Now type mv first.txt csci180/
- Do an ls. You should see that first.txt is no longer in
this directory.
- change directory to csci180 and list the files in the
directory. You should see first.txt and lab1 in this
directory.
- removing files
rm filename removes the file.
- type cd to get back to your home directory
- type rm secondfile.txt
- 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
- removing directories
rmdir directory removes a directory;
the directory must be empty.
- cd into csci180/lab1
- do an ls to see if there are files in the directory
(firstfile.txt should be there)
- do a rm of each file in the directory.
- Now, type cd .. to move up one directory.
- do an ls to see the files, you should see lab1 in the
directory.
- type rmdir lab1
do an ls to verify you have removed the directory.
- 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.
- Under the Start and Programs menus, you should see a "WS
FTP" menu item; select the WS FTP program from within this
item.
- The left side is your local machine, the right side
will be your cerebro account.
- Choose connect to remote machine and enter
cerebro.cs.xu.edu; give your login and password.
- When connected you should see the contents of your
directory in the right side window.
- 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
- handin is the name of the program
- course# is the number of the course -- 180 in this case
- assignmentName is the name of the assignment -- I tell you
this.
- files is the list of file names you want to hand in
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.
- Exercise 1.13
- Exercise 1.14
- 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