CSE 115 - Fall 2008 - Banner
UB -
University at Buffalo, The State University of New York Computer Science and Engineering
  • CSE 115 - Fall 2008
CSE 115 - Fall 2008 - Navigation
CSE 115 - Fall 2008 - Lab 1

Lab 1
Last modified: September 06 2008 05:08:26 PM

CSE 115 - Fall 2008 - Lab 1

Introduction

If you followed the directions on the Lab 1 Prep work on how to get the web browser started and have navigated to this page - congratulations! You have just completed an important part of the lab process for the entire semester. Each lab will begin with you finding the description online and reading it.

In this first lab you will be introduced to the computing environment in the Baldy 21 lab. If you are familiar with Unix you may know how to do some or all of the following tasks. Do them all the same. If you are new to Unix, these exercises will get you up and running with most of the tools you need to successfully complete the lab assignments of this course. Some further tools will be introduced as we need them in later labs.

Read through the entire lab before you start working, so that you know what to expect. Make sure you save your work often, and keep track of what you are expected to submit.


Objectives

The objective of this lab is to introduce you to the Unix operating system and some of the tools available to you so that you can work on the labs independently.


Preparatory work

Be sure you completed the preparatory work outlined in the Lab 1 Prep Work.


Lab Tasks

Your instructor has briefly gone through the tasks listed below during lecture to help prepare you for this lab. You must now carry out each of the following tasks on your own in the lab setting.

Logging in - Connecting to the system

Your first lab task is to log in to your CSE computer account. Your CSE account is valid on the computers in Baldy 21. This account is separate from your UBUnix account.

  • If you have not had a CSE account previously, your login name is the same as your UB-IT name. Your password is the same as your UB-IT password was at the time when your CSE account was created.

  • If you have previously had a CSE account (e.g. if you took any other CSE course last year where you received an account), your login name and password should not have changed.

Linux (a Unix variant) is the name of the operating system that is running on the machines in the Baldy 21 lab. An operating system (or OS) provides basic services to both programs (applications) running on the machine and to users who are working on the machine. Examples of services provided by an OS are a facility to read the contents of a file from a disk, or run multiple programs at one time (multi-task).

To log in:

  • You should see a welcome screen with a place for your username. Enter your username (UB-IT name), and then press OK.
  • You will then be asked to enter your password. Enter your password, and then press OK.

When the login process is finished, you will be presented with a desktop. There will be a few icons on it that looks like this (your background may be slightly different):
Desktop
There is a panel across the top of the screen which has two menus on it. This is similar to the Start Menu feature of Microsoft Windows. There is also a panel along the bottom of the screen. If you want to know what anything does, hover your mouse over it and a little description will appear.

In case of emergency where you suddenly need to leave, such as your grandmother dying (it happens a lot in this class), let's discuss how to log out of the system before we go any further.

  • Just click on the "Actions" on the panel at the top of the screen, then select "Log Out".
You will probably receive a message asking if you're sure you want to log out. There's also a checkbox that says "Save current setup". If you want to save your setup (that is, whatever changes you've made to your personal computing environment), check this box. Then click on "OK" and you will be logged out. Remember to never leave the lab without logging out, even if it is "just for a minute"!

Spend a moment getting comfortable.  To move a window with a title bar (for example double click on 'Computer' to get a window), click and hold the left mouse button in the middle of the title bar and drag it to a new position. If you click on the small buttons in the title bars of the windows, different things will happen (this is similar to what buttons on Windows will do, but remember that on every new OS you explore, the buttons on windows could do different things, so you should not rely on a button always being in the same place from OS to OS):

  • The rightmost button on the title bar:
    Left-clicking this will close the window. Try it out: open a window and close it.

  • The button to the left of that (in the middle of the three):
    Clicking this will toggle the window between "maximized" and "unmaximized"/"normal" modes. In maximized mode, the window will take up the full space of the screen. In normal mode, the window is not necessarily the full size of the screen and you have the ability to move it around and see other things on the screen as well. Try maximizing and unmaximizing some window.

  • The button to the left of that (the left side of the three):
    Left-clicking on this will minimize the window. It keeps the program running but hides it from view. Now we need to get it back. Just click on the corresponding item on the panel along the bottom of the screen.

  • The button on the far left of the title bar:
    Clicking on this will bring up a menu of different things you can do to the window. Try it out and see what can be done.

To interact directly with Unix, we need what is called a terminal. Here are two ways to bring up a terminal:

  1. Right click on an empty space on your desktop and select "Open Terminal" from the menu.
  2. Click on the Applications menu on the panel at the top of the screen. Click on "System Tools", then click on "Terminal".
The terminal window will look like this:
Terminal Window
The > symbol is called a prompt.  You will type commands into the prompt to get the Operating System to perform various tasks for you.

The files which you create are stored on a machine called a file server, which is accessible from all of the workstations in the lab. In other words, it doesn't matter which workstation you log in at, you will be able to access exactly the same files. The computer which you will use in the Baldy 21 lab is called styx.cse.buffalo.edu, or just styx for short. This computer shares its files with several systems, one of which is called timberlake.cse.buffalo.edu (timberlake for short), which you can log into from other places around campus or from your house or dorm or apartment. Remote connections should always go through timberlake.

Changing your Password

It is a good idea to change your password from your default password to something else. You should change your passwords often to help keep your account secure. You must never share your account password with anyone (including your friends and classmates). You can choose to change your password now or come back to these instructions and change it at a later time.

To change your password on the CSE systems type (at the prompt)

passwd

You will then see:

Changing password for user <Your UBIT name here>.
Changing password for <Your UBIT name here>
(current) UNIX password:

You will then need to type in your current password and hit enter. You will not see anything come up while you are typing your old password. Then you will see:

New UNIX password:

Choose your new password and type it in and press enter again.

Retype new UNIX password:

Retype your password and then hit enter one last time. You will then see the message:

passwd: all authentication tokens updated successfully.

The next time you log in, you must use the new password you just sent. If you forget your password, send mail to cse-consult@cse.buffalo.edu from a UB account and they can reset your password for you.

Because your CSE account is separate from your UBUnix account, changing the password on one account does not automatically change the password on the other. You should change passwords on both accounts on a regular basis.

E-mail

Since you have a UB-IT account (i.e. an ACSU or UBUnix account) you also have an e-mail address @buffalo.edu. You cannot receive e-mail at this account until you enable it (even though you can send e-mail from this account without needing to do anything special). You should have enabled your UBUnix e-mail account before coming to your lab session. If you have not already enabled this e-mail account, do so now by visiting https://email.buffalo.edu/cgi-bin/enable.pl. You may be asked to log in with your UBIT and password - this is not logging into CSE, but rather the University-wide systems.

You can configure many different email programs to read your UB email. Take a look at this page for some of those options http://ubit.buffalo.edu/mail/configure_email.php.

Right now, you should experiment with UBMail (https://ubmail.buffalo.edu/). You can use this web-based interface to read your UB email from any web browser. If you choose to forward your UB email to another provider, you can visit this page (http://ubit.buffalo.edu/mail/forwarding/).

There is a CSE e-mail system that is separate from the main UB e-mail system. You can choose to maintain two separate and parallel e-mail systems for yourself (make sure you read e-mail at both sites). An alternative is to designate one as your primary e-mail system, and to forward your e-mail from your secondary e-mail service to your primary. When you account was created, it automatically forwards your CSE email to your UBUnix account. If you would like to maintain two separate email accounts, just delete the .forward file in your home directory and set up your main UB email to forward to CSE.

If you coose to maintain two separate email accounts, you can use various graphical and textual programs to read your email. Directions for how to set these up are located here.

Whatever option you choose for your email, you should be sure to read it daily and respond to any questions from your instructor or TAs as quickly as possible. If you are using an email client that is not UB-based (like gmail or others), you must have a way of sending email from your UB account so that we know who is sending us the email (using UBMail when sending mail regarding courses is a good option - you can still read email from wherever you like).

If you have never sent an email before, you are encouraged you to do so now (if you don't know any email addresses, send it to yourself).

 

Some Basic Unix

In this section, you will experiment with some basic Unix commands, and learn a little bit about the way in which Unix organizes its file system.

Basic Unix directory structure

Like most file systems, Unix's is tree-structured. The root of the file system is named '/'. As a user on the system you have a home directory, where all your files are stored. Unix has a "shortcut" to represent your home directory. This shortcut is the tilde (~). Whenever you want your home directory, you can just type ~. To find out where your home directory is, type

echo ~

When I do this, I find out that my home directory is /home/csefaculty/adrienne. This means that my home directory adrienne is located in the subdirectory csefaculty, which is a subdirectory of home, which is an immediate subdirectory of the root directory (which is, as mentioned above, designated by '/'). "/home/csefaculty/adrienne" is a path which describes how to get from one directory (in this case the root directory) to another (in this case my home directory). A path can either be absolute (starting at /) or relative (starting at the current directory).

Every directory has two special entries, . and .. The entry . refers to the directory itself, and .. and refers to the directory's parent directory (i.e. the directory of which this one is an immediate subdirectory). The . and the .. are "shortcuts" as well. No matter where you are, if you want to use your parent directory, then you just use ...

The root directory is the only directory in the file system which does not have a parent directory. (Actually, this is not quite accurate. If you inspect the root directory you will find that there is a .. entry. The parent of the root directory turns out to be the root directory itself!)

Some Unix Commands
Below I have listed some basic Unix commands. Read the description of each, and carry out any exercises given. Note that many of these commands are equivalent to what you can do in a graphical environment, and there is a file explorer available to you on your desktop, but these can serve as a reference in case you are in a Unix environment with a graphical system on top of it.
  • ls - This command gives a listing of the files in a directory. Without any arguments, it provides a listing of the files in the current directory, and is therefore equivalent to

    ls .

    If you specify a directory using a path, ls will respond with a listing of the contents of the specified directory. Try typing ls at the Unix prompt.

  • cd - This command changes the current directory. Without any arguments, it changes the current directory to your home directory, and is therefore equivalent to

    cd ~

    If you specify a directory using a path, cd will set the current directory to the specified directory. One neat thing is that using .. as an argument to cd moves you to the parent directory.

  • man - The man command brings up a manual page (help screen) for a specified command. Let's get the man page for the finger command by typing man finger.

  • mkdir - This command creates the specified subdirectory.

  • cp - This command copies a file to a new location, leaving the original unchanged.

  • mv - This command moves a file from one location to another. But beware, because of the way file systems work, moving a file is very similar to renaming. The mv command is also the rename command.

  • rm - The command rm removes a file. This command is not (easily) reversible, and it will not ask you (by default) to confirm your delete action. Hourly snapshots are taken of the files on the system that can help you restore something if it is accidentally deleted. These snapshots are located in /u0/.snapshot and then are kept by the hour (0 being the most recent snapshot). When you get into the hour, you use your path to navigate to your directory and then you can copy the files from the snapshot back to your home directory.

  • rmdir - This command removes the specified directory.

Running a Program on Unix

At the prompt, type the command /projects/CSE115/Setup/115setup . This command runs a script on the Unix system that does a number of things behind the scenes to get you set up to work on the labs. The one thing that you can immediately notice is the creation of a file called cse115.epf in your home directory (how do you know it's there - use the ls command at the prompt to see it). This file will be used when we start developing programs. Note that after you type the command and press Enter, you simply get the prompt back. This is common in most Unix commands that no report back is success and only failures are reported.

Beginning Your Setup of Eclipse

Create a directory in your home directory named cse115.

Change directories into that directory (using cd).

Make a directory named workspace.

Now you need to open Eclipse. There are a few ways in which you can do this. You can type the command to launch the program into the prompt. That command is /util/eclipse/eclipse &. However, you can also simply go to Applications -> Programming -> Eclipse and it will start up Eclipse for you.

When you start up Eclipse, you will see the following screen:
Eclipse Splash Screen

Then you will see a Window that will ask you which workspace you want to open. By default, it will probably say something like this:
Workspace Launcher
You do not want to use this default workspace. Use the Browse button to make the workspace point to the directory you just made named workspace, like this:
Workspace Launcher Correct

Be sure to check the box "Use as default and don't ask me again", and then click "OK".

You will then see a screen that looks like this. You will choose the arrow to take you to the Eclipse workbench.
Eclipse Opening Screen

You will then see the default workbench setup. The TAs will talk about customizing this and changing it around throughout the semester. You don't ever have to customize the Eclipse workbench, but we have some suggestions for making life easier when working on projects for this course.
Eclipse Workbench

Import preferences file

Next you need do tell Eclipse a few things about how you want it to behave. This is a one-time process. In other words, once you have successfully carried out these steps you will NOT need to repeat them in lab. If we take care of this during this first lab, you won't have to do it when your goal for the week is to complete a coding project, so we'll have you do it now and get it over with.

Earlier while working on this lab, you ran a script from the prompt. This script put a file in your home directory named cse115.epf. You should check to see that this file is in your directory by typing ls again. If you do not have the file, you should run the script again by doing the following:

At the prompt, type /projects/CSE115/Setup/115setup and hit Enter. After you do this, the file named cse115.epf should be in your home directory.

To import the file, you will first need to open the Import dialog. Do this by selecting "Import..." from the "File" menu. It is common practice to abbreviate menu selections that you need to make in instructions like these. For example, we can abbreviate

select "Import..." from the "File" menu
by simply writing "File" -> "Import". This time we'll show the screen shot of the menu item being selected, but from now on we'll simply write menu selections using this abbreviated method. Your teaching assistant can help you if you have trouble locating the correct menu selections.

File-Import

An "Import" dialog window should appear.

Import Dialog

Select the + sign (or the > symbol depending on your OS) and expand the "General" Folder. Note that there is now an option for "Preferences", as below. Select it and then click "Next".

Import Dialog Preferences

This opens up an "Import Preferences" dialog window. Browse to the file cse115.epf in your home directory and select it.

Import Preferences

The rest of the options should be OK as they are (they should be as in the screenshot above - if not, make them the same). Click "Finish".

 

Seeing the connections to code repositories

If you do not have a tab in the lower portion of your screen that says "CVS Repositories", you should open that View so that you can see what Repositories you have connections to. To do this, select Window -> Show View -> Other. You should then select to expand the entry for CVS and select CVS Repositories and click OK. You will now see a view tab on the bottom of your screen that shows which repositories you have access to:

CVS Tab

Notice that in the repositories tab, you will see repositories for the lecture code that your instructor has been working on in class as well as the code you will need for the assignments this semester. At any time, you can view any of the code we will been using in class.

If you encounter problems, ask your recitation TA for help.

To gain credit for this lab, you need to ask your TA to come over and show him/her that you have successfully opened up Eclipse, that you have created the proper directory (cse115) in your home directory, and that you successfully imported the preferences file and can see the code repositories. Once you have done that, you will receive full credit for the lab and are free to go. However, you should also feel free to explore the systems in Baldy 21 in the remaining lab time or on your own.

In next lab, we will finish the last bit of setup for Eclipse and begin working with some of the tools built into Eclipse and write some Java code.


Due dates

Since this lab must be completed in the alloted lab time, the due date for the lab is by the completion of your scheduled lab time during the week of September 1st.

 

CSE 115 - Fall 2008 - Footer

Page maintained by Adrienne Decker

Contact: adrienne@cse.buffalo.edu | 130 Bell Hall | (716)645-3180 x 161