Lab 1: Logging on and using Unix

Handed out: January 25

Due on: January 31, by midnight

This lab is a sure route to quick and easy points. It is meant to get you started and comfortable with the Unix computers that we will be using throughout the semester.

The computers we will be using are standard PCs, running a version of Unix called Linux (sounds like cynics).

Logging in

You already have your login name and password, that was given out to you on the first day of the class. If you don't have it with you, see the TA or the instructor. If you have misplaced the chit with your login/password, please see the instructor.

Sit at a computer that is one of the group of the computers that the lab instructor has designated. If the screen is blank, hit the <enter> key. Something should appear. If it doesn't, tell the lab instructor and find another computer to use.

You should either see a login window in the middle of the screen, or a login prompt in text at the bottom of the screen. At the login: prompt, enter your username, and hit <enter>.

You should now have a password: prompt, (or if you have a login window, the cursor should be in the password field). Enter your password and hit <enter>. Note that nothing will appear on the screen while you are entering your password (or maybe *'s will appear for each letter you type).

If something goes wrong, you will see Login incorrect, and a new login prompt will appear (or in the window the window will just clear and wait for another username in the login window). Try again. If it fails again, contact a lab instructor.

When it works, if you logged in through a window, you will eventually see a GUI, a graphical user interface, like Windows or the Mac, but also different. You should have at least one window where a command prompt is waiting for you to type in commands. This window is called a terminal window, and the program controlling the prompt is called a shell.

If you logged in on a text window at the bottom of the screen, you need to start the GUI. You do this by typing in startx, and hitting <enter>. You should have some windows appear on your screen.

Using the terminal to start Netscape

Now, move the mouse pointer around, in and out of your terminal window. You should see the border of the window change color. When the mouse pointer is in the window, the window is active, and you can type commands into it. When it is outside of the window, whatever you type does not go into that window, and the commands aren't executed.

Now, let's start Netscape. You do this by pointing to the terminal window, and entering netscape & and hitting <enter>. The ampersand tells the shell not to wait for this command to finish, but to continue to accept other commands right away.

Now that you have Netscape running, you can go to the Web pages for this class. In the box near the top of the Netscape window, with Location: in front of it, enter

http://www.cs.nmsu.edu/~gupta/Classes/CS171

and hit <enter>. The home page for this class should appear -- it is exactly just the syllabus that was handed out in class.

What is Netscape?

Netscape is a browser for the World Wide Web. It lets you look at Web pages -- which are documents that have text and pictures on them. Documents have a name, called a URL, or Universal Resource Locator. This is what is in the Location field, so for our class the URL is

http://www.cs.nmsu.edu/~gupta/Classes/CS171

Documents can link to one another -- wherever you see underlined text, that text is a pointer to another document. You can go to the other document simply by clicking on the text (the mouse arrow shape changes to a little hand with a finger pointer). There are buttons near the top of Netscape that say back and forward -- these let you go back to your previous documents, or forward as well.

Exercise 1: Learning about Unix

Now it's time to learn more about Unix. We will do this by browsing Web pages and doing some exercises. In the location box, click to bring up the prompt and change the URL to be

http://www.cs.nmsu.edu/~gupta/Classes/CS171

This URL has a pointer to the CS171 page, but also has pointers to other things. Click on the "class schedule is available" in the description section. Click on the 3rd line that says (A Brief Introduction to Unix). For this lab, you must go through the lessons one by one, in order, answering the questions below along the way. You need to hand in your answers to these questions. Each lesson has a pointer to the next lesson at its end. Click on this pointer to get to the next lesson

Exercise 2: Create/save a file, compile/run a program

At the command line on a window type "xemacs prog.java". A window will pop up where you can enter text. The xemacs tool lets you create and modify files. Type the following java program shown below in the blank area:




class test {

public static void main(String[] args) {

System.out.println("hello from the computer");

}
}


Make sure that the program is typed exactly as it appears above. Now click on the "save" button. This will cause the program you just typed to be saved in a file called prog.java. Next time when you return to the Lab, typing "xemacs prog.java" will cause the content of this file (the program you typed) to be displayed in the xemacs window. At the command line, type:
javac prog1.java to compile your Java program. Now run the executable by typing the command java test See what is output on the screen.