Lab 0: Introduction to Linux and Firefox

Lab Objectives

  • Gain exposure to the graphical and command-line interfaces of the Linux operating system.
  • Setup access to online course information through Firefox

Getting started with Linux:

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, enter your username and password (the same that you use to access myRC and email) and press Enter. 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 you will be storing your files and running programs from a remote computer (named "CS"). This means that you can use any computer in the lab and still be able to access your personal files.

You should see a desktop environment similar to Windows. This is GNOME which is responsible for providing a graphical, desktop interface for Linux. Here are some of the basics for getting around in Gnome.

The GNOME panel can be customized by adding and deleting icons and moving them around. In this course we will regularly use three applications: X-terminal windows (for typing in shell commands), Emacs (a text editor for writing programs), and Firefox (for an online copy of lab instructions and sending email to the instructor). It would be helpful to add icons for these on the panel.

Launch an X-terminal window (an xterm) by clicking the icon on your panel. You should see a window appear that has nothing in it except a command prompt. A prompt is a special character or sequence of characters letting you know the shell is ready to accept commands - the prompt on the lab machines contains your username, the machine name, the pathname of the current directory and a dollar sign. The dollar sign is one of the standard UNIX prompts. The Linux commands (called shell commands) are typed in an xterm at the prompt -- more on shell commands later.

Now open Firefox using the icon on the panel.

You should now have two windows open. You can use the mouse to move and manipulate these windows and open programs in the same way you do in other GUI environments that you are familiar with. As in other systems you can also use key strokes to do many of the same things and often that is faster. Here are a couple you may find useful.

  1. Moving Windows: As usual, windows can be moved by clicking on the title bar but an alternative is to 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.

  2. Activating a Window: Clicking inside a window or on its titlebar both activates the window and brings 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.

Setting up Firefox

Firefox is an open-source web browser that looks and acts much like Internet Explorer, Safari or Netscape. Open Firefox by clicking on the icon on the panel. First, we want to set the class webpage to be your homepage. Under the Edit menu, select Preferences. The preferences dialog will open, and on the right you should see a textbox for Home Page.

If you are in Dr Ingram's class, type in:

http://cs.roanoke.edu/CPSC120A 
If you are in Dr. Bouchard's class, type in:
http://cs.roanoke.edu/CPSC120B 
Close the dialog and press the Home icon to go to the class web page. Look over the page; note that it contains links to the syllabus, to various useful information, and to the assignments (none yet) and labs. Click on the lab0 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.

Using the Command Line Interface

While pointing and clicking is familiar and fairly intuitive, it is not always the most efficient way to give commands when working with a computer. For this reason, many computer users, especially programmers, prefer to interact with the computer system by typing in commands that explicitly tell the machine what to do. The command-line interface for Linux systems is accessed through an X-terminal(xterm).

Activate the xterm you already have open. The program running in the xterm is called the shell. The shell lets you issue commands explicilty to the Linux operating system and work with files. The following leads you through using some of the basic commands in Linux. 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.

  1. How do you find out "where you are" in the file system? The command is pwd which stands for present working directory. To find out where you are now type pwd

    What is displayed when you type in the command (and press ENTER)?

    ___________________________________________________
    (Note - this should be the full pathname of your home directory - you are always in your home directory when you first log in.)

  2. How do you change to another directory?

    The command is cd (for change directory) BUT you must also type in an argument specifying the directory you want to change to (give either an absolute or relative path to the directory). Note that for any Linux command with an argument you must type a space between the command and the argument.

    Let’s go to the root directory (also known as “/”).
    To do so, you need to type

                    cd  /
    

  3. How do you see what files are in a directory?

    The command to see the files in your current directory is ls. To see a list of files in a different directory you need to add a pathname to that directory as an argument.

    Look at the files that are in the root directory (that's where you are!) by typing the ls command.  

    You should see quite a few files including one named etc. It is one of the system directories mentioned in the Linux/Unix Overview handout. Now do the following:

  4. How do I get more information about the files?

    Use the -l option on the ls command; that is, type ls -l (that is an el for long, not a one) to get a long listing of the files.    Type the command to see info about the files in the etc directory. Note that this shows you the permissions on each file (described on the last page of the Linux/Unix Overview), the ownership and group for the file (most of these are root), the size of the file (number of bytes), and the date of last modification of the file.

    Note that some of the filenames show up blue and some are black (you will see two more colors if you scroll up - green and light blue). The file permissions are displayed in the first column (this is the sequence of 10 characters described on page 3 of the Linux/Unix Overview handout). What do you notice about the permissions on the blue files versus the black ones?

  5. Now change to the “bin” directory. Recall that bin is a subdirectory of root – but we are now down one level in etc (see diagram on page 2 of the Linux/Unix Overview). So we can change to root in one of several ways:

    Now type the command to list the files in bin.   Note that a lot of the files contained in this directory are displayed in green.   You may also notice some familiar file names (cp, ls, pwd, for example).  

    Type ls –l and examine the permissions on the green files. What are the permissions for all users?
      What do these (green) files all have in common?   


  6. How do you find permissions for a specific file?

    To do this we need to add the filename as an argument to the ls command. For example to see the permissions on the file cp type:

                  ls -l cp
    
    Make a note of what happens (especially the permissions).

  7. How do I go back to my home directory?  

    This is an example of changing directory so you need to use the cd command. As before you could use it with an argument that gives the pathname of your home directory. However, the fastest way to change to your home directory, is to just type cd

    Other options include:

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.

Using Emacs, the Text Editor:

Launch Emacs by clicking on the Emacs icon (a letter E stylized to look like the horns of a gnu) 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.

Exit Emacs by typing C-x C-c OR choose File, Exit Emacs.

Printing

Before printing you need to set the default printer. On the Panel choose System, then Preferences, Default Printer. Choose the MCSP lab printer then click Set Default.

To print out your answers, use the enscript command in your xterm (shell) window as follows:

enscript -2rG UnixQuestions

This requests that the file UnixQuestions be printed on the lab printer. The additional parameters to the print command tell the printer how you would like the document formatted. Specifically, you are asking for 2 columns, rotated to landscape orientation and add a Gaudy title.

Do not print from within the text editor; always use enscript
Do not print from within the text editor; always use enscript
Do not print from within the text editor; always use enscript

Mail Your Answers

In Firefox 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://webmail.roanoke.edu). Bookmark this link - you will use it every lab to submit your work via e-mail.

  1. Click on the New Message button in the upper-left hand corner, and address the message to your instructor (bouchard@roanoke.edu or ingram@roanoke.edu). Put lab0 in the subject line.
  2. Click Attachments, then Browse, and find your UnixQuestions file 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 Attachments.

  3. To return to the message composition screen, click Done. You should see your filenames next to Attachments. Now, send the e-mail.

Log off myRC then close 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 Quit. In the next window, select the "Restart" 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.)