CSC120 Lab #1





In this lab you will be given a crash course in UNIX. Your TA will go through this lab step
by step. Be sure to ask questions at any time if you get lost.

Logging In

Your login name is made up of the initials of your First and Middle name along with the first two
letters of your last name. Then add on the number 120.
Your password is the same four letters of your login name along with the last four digits of your
social security number.
For example:
Name SSN Login Password
George W Bush  111-22-3344   gwbu120   gwbu3344
Albert Gore 123-45-6789 agor120 agor6790
Cher 000-00-0012 cher120 cher0012

If your name does not fit one of these then ask your TA for help.

Basic GNOME desktop environment

There are several layers to the modern day computer system. The most important layer of course is the actual operating system which controls file handling, memory access, program execution, and most other operations of the computer. In our case, this is the RedHat version of Linux, a UNIX-based system. For Windows users, this is the same layer as the Windows operating system itself or DOS.
Interacting with the Linux OS is traditionally done using shell programs. This is similar to the COMMAND prompt from Windows/DOS. There are many shell programs available for Linux systems. The main two we have here are bash and tcsh. For the most part, you will be using the bash shell program. These programs let you type in commands to run other programs, view particular files, create new directories, and navigate around the system itself. The better ones also have such features as a history - so you do not have to retype your commands again - and even a rudimentary programming language allowing you to run shell scripts. Again, for Windows/DOS users, this is like a batch file. In this lab, though, we shall only discuss the most fundamental commands to get everyone started.
Now, with the advent of window environments like Windows and the Mac OS, users are used to more than just a text screen, which is all shell programs really let you do. The program called X Windows gives the Linux computer the ability to display windows (among other features). However, X Windows does not create the window style itself. No, there is one (actually two, but who is counting) more layer called the window manager which controls the features of your desktop environment. In our case, we will be using the GNOME environment. Other popular window managers available to you are KDE and fvwm2 to name a few. Once again, Windows systems have their own window manager which is basically the Windows window manager - not sure if there is a more specific name for it.

The first thing to know about the GNOME window manager is that it is VERY configurable. If there is something you don't like about the system, chances are you can alter it, though the ease at which it is done may vary.
The next thing to know about the GNOME window manager is that the main programs are popped up from the menu bar at the bottom (by default, but this can be moved to any of the four sides of the screen). In particular, left click on the "foot" at the bottom left side of the screen to see a menu of sorts.
Next lab will deal a little more about the GNOME environment, but in the meantime feel free to play around with the system. Practice builds experience.

UNIX Shell

Once you are logged in, the first thing to do is to start up a unix shell session. To do this, what you really need to do is open up an Xterminal. This is a window which acts like its own screen for running the shell programs mentioned above and communicating with the OS. Opening up an Xterm is quite easy. The simplest method is to click on the icon in the menu bar with the picture of a monitor and a foot together (probably near the Netscape logo - N).
The next thing to do is startup Netscape - click on the icon with the N. This way you can browse this documentation online at the home page:
students.cs.miami.edu/~csc120
Make sure your mouse is over the window you wish to be using, otherwise, anything that you type may be going to a different window. Now the first and most important thing to do is to change your password.
First though, come up with a good password. Do not choose simple words. Use capitals, numbers, and
odd characters like ! & * (). Passwords on all accounts are frequently checked and if your password is broken then you will be locked out of your account and will have to see the System Administrator. For more hints on how to choose a password visit this link:
www.cs.miami.edu/~irina/password.html
In the shell window you should see what is called the shell prompt. There are many ways to display a prompt. I believe you current one looks like this (under bash):
[userid@machineName userid]$
Another possibility and the one we shall use to designate the prompt in all work is the following: %
By the way the funny name in your prompt is the name of the machine that you are working on. They are named after civil war battles. Type in the change password command:
   % yppasswd (Note you do not type in the "%" sign, that designates the prompt.)
You will be prompted to enter your current password and then to enter your new password twice. Please remember you password, if you forget it you will have to see the System Administrator.

Creating Text Files

At the command prompt type in the command:
   % xemacs &
The ampersand (&) at the end designates that the program is to be run in the background so that the shell command does not "lock up" and wait for the program to exit. This will open up a powerful (not so graphical) text editor. You may also use a simpler graphical editor called "gedit" or "gnp" (gnotepad). Type in some text here and save it as "test.txt". The TA may give some instructions on what info to enter here.
Xemacs is the recommended editor for writing and editing your programming assignments. If you are working from home, you will probably need to use another similar version called emacs.

E-mail

There are many email programs available as well. I use Netscape mail but many of you may want the most convenient mail available. For this, I recommend either pine (non-graphical mail browser) or exmh (X-windows mail browser). Of course, I still prefer Netscape mail. To use pine, at the command prompt type in:
   % pine
To use exmh, at the command prmompt type in:
   % exmh &
Now, send an email along with the file "test.txt" that you created in the last section as an attachment to your TA and CC the message to yourself. Your email address is your login name followed by @mail.cs.miami.edu. Thus, for the examples above it would be:
gwbu120@mail.cs.miami.edu
agor120@mail.cs.miami.edu

Basic UNIX Commands

Here is a list of useful commands along with a brief description.
Command Description
mkdir dirname Make the directory with name dirname
cd dirname Change the directory (go to the directory dirname)
cd Go to your home directory
cd .. Go to parent directory, one level up, note the space between d and .
pwd Print working directory
ls List what is in the current directory
ls -l Long list what is in the current directory
ls -a List all files, even the .name files (which are otherwise hidden)
rm filename Delete the file filename
rmdir dirname Delete the directory dirname (only if it is empty)
mv oldname newname Rename the file or directory, technically, move the file to another location
cp filename1 filename2 Copy file filename1 to filename2
xemacs & Recommended editor for editing and creating your programs
emacs -nw Original emacs, with -nw, tells the computer to start program without creating a new window. Very good for when you putty (ssh) in to students from home.
pico Another text editor, good for when you putty in to students from home
pine E-mail program, good for when you putty into students
cp ~/Lab1-1/HelloWorld.java ~/Lab2-1/   Copy the file HelloWorld.java from Lab1-1 directory into Lab2-1 directory
man ls Bring up the Manual page for the ls command (or almost any command)
man -k java Search the Manual page index for all references to keyword java (or any keyword)
treepr filename Print the text file filename The more daring person may wish to use enscript to have more control over the output. Use man enscript.
lpr filename Print the Postscript file filename
javac HelloWorld.java Compile the program HelloWorld.java
java HelloWorld Run the program HelloWorld

Your TA will lead you through a few examples and explain what is happening along the way.

Your First Program

Lab1: HelloWorld
Create the directory Lab1 under the directory classes and save the following program in there. Save it as HelloWorld.java


   // George W Bush
   // gwbu120
   // Assignment Lab1-2
   //
   // This is my first program. It prints Hello World.
   import java.io.*;
   public class HelloWorld {
      public static void main(String[] arg) {
         System.out.println("Hello World!");
      }
   }

Your TA will explain to you how to compile and run the program. Note, see above UNIX commands.

Forwarding mail

If you want your mail to be forwarded to another email address, here is what you do. In your home directory (type in % cd), edit (or create) the file .forward using xemacs or any other text editor. Each line of the .forward file represents an address to forward all incoming mail to. So, to forward mail to clinton@whitehouse.gov, the .forward file would have the following text in the first line...
clinton@whitehouse.gov