Linux/Unix Overview

The operating system we will use in this course is Linux, an implementation of Unix. There are many implementations of Unix, with mostly minor differences between then. We will loosely use the terms Linux and Unix interchangeably. Additional software tools that we will use include Gnome, a desktop environment; Emacs, a text editor; and Mozilla, a web browser. You will gain familiarity will all of these tools in an in-class lab. This handout gives you an overview of a few Linux/Unix concepts.

The Roanoke College Linux Server:, commonly known as CS.

Booting into Linux To start up a computer one must go through a process called booting the system. During the boot process, the system checks the hardware on the machine and then loads the operating system -- brings it from auxiliary memory (usually a hard disk) into main memory (RAM). The computers in the Trexler labs are dual boot systems that can load either Windows XP or Linux when booting. During the boot process, the system pauses briefly and displays a graphical menu asking which operating system to load. The default is Windows XP, but you can direct it to load Linux instead. The in-class portion of the lab gives instructions for booting the machines into Linux.

Linux and Gnome When you log into Linux from the Roanoke College labs, you are in a desktop environment that looks much like Windows. This is a public domain X-Windows system called Xfree86 that uses the Gnome desktop manager in addition to window management software. It is important to understand that Linux is the operating system; it maintains the file system, executes user commands, provides security, and so on. Gnome just provides an easy-to-use, window-based desktop environment on top of Linux.

The Shell

For all the fancy environment, much of your work here (and on most Unix systems) will be done in a command line shell. A shell is a program that interprets operating system commands you type in. It receives commands you enter as input, interprets them, and takes appropriate action (i.e., if the command was correct, it is executed; otherwise you are given an error message). The shell is the basic way for the user to interact with the operating system. There are many shells available for Unix operating systems, each having its own set of commands (with a large core of common Unix commands). The Bourne shell, written by R. S. Bourne, was the original Unix shell. The C-shell is another popular shell. The shell that we will be using is called bash or the "Bourne again" shell. This particular shell provides many of the features of standard Unix shells plus several enhancements.

The Unix File System

User data (such as a research paper or a program) and system data (such as password information and the machine code for carrying out operating system commands) are stored in files on a computer. One important job of the operating system is to manage the storage of these files in auxiliary memory (disks, usually). The Unix operating system, like most others, organizes the files in a hierarchical, tree structure. Most files are either regular (also called ordinary) files or directories. Regular files (usually just called files) contain text, programs, or other data. Directories contain names and addresses of other files and directories. Directories are called folders in some operating systems such as Windows XP. Some special directories are as follows:

A part of the Roanoke College Linux file system may be visualized as follows:

      |       |             |                   |
      |       |             |                   |
 ... etc     usr           home                bin     ...
                      |                       |                |
                      |                       |                |
                   students                 staff          department
                      |                       |                |
                      |                       |                |
            ------------------            ---------           ------
           |                  |          |         |          |     |
           |                  |          |         |          |    ...
         jdoe                bozo      ingram    bloss      cpsc    
           |                  |          |         |          |
           |                  |          |         |          |
        ---------            ---------  ...       ...         |
       |         |          |         |                       |
       |         |          |         |                       |
      ecom  public_html    cs120  public_html               public_html
                            |            |                     |
                            |            |                     |
                         myPage.html     |                  May2002
                                         |                    |
                                     LabQuestions             |
                                                      |             |
                                                  index.html   syllabus.html

File Names

In general, a file can always be referenced either using its full (also called absolute) pathname or a pathname that is relative to the current working directory. An absolute pathname gives the path of the file through the tree starting at the root /. Subdirectories along the path are separated by slashes. A relative pathname gives the path from the current working directory.

Example: Consider the file named myPage.html in the cs120 subdirectory of a student with username bozo (see the diagram above).

The hierarchical file structure used in Unix is similar to that used in Windows XP and the earlier MS-DOS systems. (In fact, MS-DOS borrowed its file structure and many operating system commands from Unix.) One difference however is that Unix does not use the idea of drive letters for physically different disk drives (for example, A for the floppy drive and C for the hard drive). There is only one system with each separate physical drive mounted under some directory. For example, the lab computers actually mount the /home directories from CS (the Linux server), while the rest of the file system is stored locally, but you can't tell this as the user -- it looks like it's all on the same machine. Hence, the one large logical file structure can physically reside on several different computers.

Basic Unix System Commands

Unix contains shell commands that let you organize your files and navigate the file structure. Some of the basic shell commands are summarized in the attached table.

File and Directory Permissions

Every file or sub-directory in a directory has a list of permissions assigned to it. Three sets of permissions are assigned: one to the owner of the file, another to the group (users may be put in groups), and the third to all others. These permissions define who has the right to look at ("read"), modify ("write"), or execute that file or directory. Permissions for a particular file or directory are shown as a sequence of 10 characters:

Some examples are



The first example indicates a regular file where the owner has read and write permissions (the r and w) but not execute permission (the -) and both the group and all others have only read permission. The second example indicates a file that is a directory where the owner has read, write and execute permissions but the group and others have only execute permission. One can see the permissions on files by using the ls command with the l (the letter "el") option (type ls -l to see permissions for all files in a directory or ls -l filename to see permissions on a given file).


The Emacs Editor

The Emacs editor can be used to create new files, modify existing files, delete existing files, manage directories, etc. All these files that Emacs can create and modify are plain text files. That is, Emacs is designed to help the user with creating and modifying files that contain nothing but character data. Non-character data such as codes that word processors use to denote boldface or italics cannot be created by a text editor. A text editor basically just lets you create "unprocessed" words!

When you start Emacs (either using the emacs command from the shell prompt, using a menu, or an icon), you get a window divided into several parts. The larger region will contain the text you are editing. This part is often called a buffer because its contents are stored in a region of memory (RAM) called a buffer. Emacs allows you to open several buffers simultaneously, a feature that we will use later in the semester when we put different parts of programs in different files. The bottom of the window contains a status line (also called a mode line) that gives you information about the buffer (its name, for example) and below that is a single line called the minibuffer which displays commands that you enter. Commands (such as save, cut, or paste) may be given to emacs in a variety of ways -- using a menu, typing the command in the minibuffer, or using special keys (primarily the control key in conjunction with other keys). The minibuffer shows each command you issue and then shows the results of the command (including error messages!).

You will get some practice with Emacs in the in-class portion of the lab.