Introduction to Linux, Emacs, and Firefox

The Login Process:

The computers in the 2nd floor MCSP lab are dual boot, capable of running Windows XP or Ubuntu Linux, an open source version of Linux. Generally you will find them running XP so you will need to reboot into Linux as follows:

After Linux has been loaded you should get a login screen. To log in:

If you have problems logging in, make sure that you are entering the correct user name and password. If you ever have password problems, go to Information Technology on 3rd floor Trexler for assistance.

You are now logged into the local machine, but part of the file system you will be using has been mounted from Linux servers (that is, you will be storing your files and using programs on the Linux servers). You should see a desktop environment similar to Windows. This is GNOME, one of the most popular desktop environments for Linux. A separate window management program is running in conjunction with GNOME but we will loosely refer to everything in the windowing environment as GNOME. Here are some basics for getting around in GNOME:

Managing GNOME Windows

The windows you will use under GNOME will feel much like those under Windows 98, 2000, NT, or XP although a few things are different. Click on the xterm (terminal) icon on the Panel to get another xterm window, then use your two windows to get comfortable with these basics:

Moving Windows: As usual, windows can be moved by clicking on the title bar and dragging the window with the mouse. Alternatively, you can hold down ALT and then click anywhere in the window to drag it to a new location. This is particularly handy if the title bar is not visible.

Activating a Window: The window that has a brown title bar is the active window. Only one window can be active at a time. To make another window active, click inside that window or on its titlebar. This will both activate the window and bring it to the front. When you have more than one window open it is often helpful to cycle through them to get to the one you want to work in. The usual way to cycle through windows in Gnome is by pressing Alt-Tab (hold Alt down, then press Tab), just as in Windows XP. Now try ALT-Tab; it should cycle through the windows.

Using Multiple Workspaces: GNOME allows you to have several different workspaces open simultaneously. For example, later in the course you may want to have one workspace with a terminal window where you are working on your personal web pages and another workspace with a terminal window to work on lab exercises. Or, you may want to have your browser open in one workspace, the emacs editor in another, or whatever. The GNOME panel shows your workspaces (a grid of 4 rectangles in the right hand corner of the taskbar -- in each rectangle smaller rectangles indicate windows open in that workspace). At this point you should have one workspace open with a window open in it. To change workspaces, just click on the rectangle.

Moving Around the Linux File System

Now that you can get around the window environment, let's take a look at an xterm. Click on one of the terminal windows to activate it. The program running in the xterm is called the shell. The shell lets you issue commands to the Linux operating system and work with files. Refer to the Linux Command Reference and Linux/Unix Overview handouts given in class as you answer the following questions and type in the appropriate commands to move around the file system. Pay attention to what happens on the screen after each command.

Setting Up Your Directory

Now we'll set up your directory with some subdirectories and copy some files into them. Do the following:

STOP!!! Before going further have the instructor or a lab assistant come over and check to see that you have your directory set up correctly. You will be asked to go to your home directory, show a listing of the files there, then go down into the subdirectories you have created and show what is there.

Emacs

Launch Emacs by clicking on the Emacs icon (a head with horns) on the Panel. You will note a menu bar and a bar of icons at the top of the window. These contain pull down menus and icons that you can use to perform many commands. However, every command can also be executed in Emacs using an Emacs function and special keystrokes. Once you become proficient at using Emacs you will probably prefer the keystroke method of giving commands.

Editing an existing file

We'll first use Emacs to edit the UnixQuestions file. To open this file in your lab0 subdirectory do the following:

Now, you are ready to edit. As in a word processor you may move around in the buffer with the arrow keys and with the mouse. Unlike a word processor however you should press the ENTER key when you are at the end of a line. Text editors typically do not provide the same automatic line wrap features that word processors do (though Emacs provides some).

A useful Emacs command: If you ever get stuck halfway into an Emacs command, where the minibuffer is asking for something that you don't understand, type C-g (hold down the ctrl key then hit the g key). This aborts the current command.

Now go to the top of the document and type in your name, then type in the answer to each question immediately following the question.

Save the file by typing C-x C-s (hold down the ctrl key then hit the x key, then release the x key while still holding the ctrl key and hit the s key) OR choose File, then Save (current buffer) from the menu.

Activate the shell window and use the ls command to list the files in your lab0 directory. You should notice that you have at least two: one is UnixQuestions and the other is UnixQuestions~ (you may have another one #UnixQuestions#). The one named UnixQuestions is your most recently saved version of the file; the one with the ~ at the end is an older version of the file (if you only saved once it is the original file that had the questions with no answers). If you see #UnixQuestions# in your list then you must have closed the file in some abnormal way without saving (for example, if the power went off this would be an emergency backup created by the system).

Now use the nenscript command to print out your answers. The command is as follows:

nenscript -2rG UnixQuestions

This tells it to print file UnixQuestions to the lab printer.

Firefox

Firefox is an open-source web browser that looks and acts much like Netscape or Internet Explorer. Open Firefox by clicking on the globe icon on the panel. First, if the Roanoke College page did not come up as the default page (probably the Ubuntu home page showed up), change the settings as follows. Select Edit from the menubar, and then click Preferences. The preferences window will open, and on the right you should see a textbox for Home Page. Type in www.roanoke.edu and click OK. Clicking the Home button in the main browser window should now take you to the Roanoke home page. Now type the following URL (be sure to use the right one for your class) into the Location box:

http://cs.roanoke.edu/Fall2006/CPSC120A (Dr. Ingram's class)

                      or

http://cs.roanoke.edu/Fall2006/CPSC120B (Dr. Hughes' class)
This takes you to the class web page. Bookmark this page by clicking on Bookmarks and then choosing Bookmark This Page. A window will pop up wanting a name and a place to store the bookmark. Accept the defaults by clicking Add. Click on Bookmarks again and you should see that this address is there. You will use it often!

Look over the page; note that it contains links to the syllabus, to various useful information, and to the programs (none yet) and labs. Click on the lab 0 link and you'll see the online version of this document. Most labs will contain links that you need to follow, so in general you will use the online version.

Now go to myrc (http://myrc.roanoke.edu), log in, and go to the Outlook tab. (Alternately: You can go straight to Outlook without going to myRC by going to http://owa.roanoke.edu) Click on the new button in the upper-left hand corner, and address the message to your instructor (hughes@roanoke.edu or ingram@roanoke.edu). Put UnixQuestions in the Subject line. Click Attachments, then Browse, and find your UnixQuestions file -- this is a graphical view of the file system, so double-click the folders to open them. When you have located the file (remember to choose the one named UnixQuestions NOT UnixQuestions~), click Open and then Attach. The filename should now be under Current file attachments. To return to the message composition screen, click Go Back to Message. You should see your filename next to Attachments. Now, send the e-mail. After each lab you will e-mail your work to your instructor.

Close Emacs and Firefox.

Exiting an X-terminal: To exit an xterm, type exit at the command prompt.

Exiting GNOME

To exit GNOME, click on the System option on the panel and choose Log Out. In the next window, select the "Reboot" option if you are through using Linux. The computer will then automatically reboot Windows XP. (If you click the "logout" option the computer will go back to the Linux login screen.)