Notes: Unix Lab 01

Unix, Operating Systems, Unix History

  1. The Unix Operating System
  2. Brief History of Unix
  3. Introduction to the network environment
  4. The Unix shell
  5. Unix command structure
  6. man pages
  7. Other sources of help
  1. The Unix Operating System

  2. Brief History of Unix

  3. Introduction to a networked environment

    The Unix environment is almost always "networked"; the various resources that you use, (such as files) are often hosted somewhere else. This allows you to move transparently among sets of computers. The Windows system can also be configured like this, but Unix allows much more flexibility. In particular, Unix can have multiple users who can connect via the networked environment, easily sharing files.

  4. The Unix shell

    The shell is both an interactive interface to the operating system and a programming language. We will be focusing on interactive use for this course. The shell acts as an interpreter between the user and the system. Commands are entered to the shell which interprets the command and performs the action the user requested.

    There are many different shells which can be used on different Unix systems. Cshell and bash shell are probably the two most commonly used shells but there are numerous others. One of the first was the Bourne shell, 'sh'. For this course, we will be using the bash shell which derives it's name from the fact that it's programming syntax is somewhat similar to the Bourne shell, but with some C-shell and other extensions, and hence is the "Bourne-Again-SHell". Most of what we will learn will apply to other shells although the syntax may vary depending on the particular shell.

    The shell is not the command window (not necessarily). Often a terminal window is thought to be the shell. Different shell can be operated within the same terminal window or console.

  5. Unix command structure

    Nearly all Unix commands follow the same basic structure in how they are entered.

    command -option argument --more-options

    An example:
    [loriotg@gollum ~] uname
    [loriotg@gollum ~] uname -m
    [loriotg@gollum ~] uname -m --processor
    i686 unknown
    [loriotg@gollum ~] uname -mp
    i686 unknown
    [loriotg@gollum ~] uname --operating-system
    [loriotg@gollum ~] uname -a
    Linux gollum 2.6.32-32-generic #62-Ubuntu SMP Wed Apr 20 21:54:21 UTC 2011 i686 GNU/Linux
    [loriotg@gollum ~] 
    The "command" will be the first item on the line. It is the program (or function) that the shell is to execute. Following the command are the options. Options generally start with a leading dash "-" and are separated from the command by one or more spaces. Options are used to modify the behavior of the program from its default action. Options are commonly one character in length and can be listed separately or combined. "Long options" are somewhat unique to Linux and free software in general and will be found less frequently on commercial Unix systems. They are generally more descriptive than the typical command options and begin with a two dashes "--". Command arguments can be used in many different ways depending on the command. They can modify the behavior of the command or tell the command what data, files or systems to act on. Remember that all commands and options are case-sensitive.

  6. man pages

    To get help on a unix command, the most common source is the manual pages. The man program is used display the manual page for a program.

    man programname

    As an example, if we wanted to get more information about the man program we could enter:

    man man

    If found, the man program will display the page in a viewer on the terminal. Manual pages are structured in the same manner for each command. They start with the "name" which names the program and provides a very brief description of the program. The "synopsis" section shows how the command is implimented with an often overly verbose example. The "description" section will explain what the command does and how it works. The "options" section explains how each available option will modify the behavior of the program. There are several other sections which may follow in the man page depending on the command. The man page viewer can be terminated by hitting the "q".

    The collection of man pages may be searched with the apropos command. This will allow a simple keyword search of the brief descriptions for each command. The option "-k" to the man command will also perform the apropose search (Example: man -k uname).

    The whatis command does a similar search as the apropos command but searches the command names instead of the descriptions.

  7. Other sources of help

    There are number of other sources of help on a Unix system. Many programs will display a brief help description if entered with the long option "--help". This is typical for GNU utilies found on Linux and FreeBSD but less often on commercial versions of Unix.

    The GNU project also provides "info" documents for their help files. The info documents are often much more descriptive and allow browsing between chapters rather than a linear stream of text like the man pages. Unfortunately the info viewer is much more complex to navigate and will usually require some effort to learn how to navigate. The info viewer is invoked with the command info.

    On Linux systems there is usually a collection of documents found on the file system in the /usr/doc/ directory. These can be in many forms (plain text, postscript, html, pdf, etc.) The information here is often more detailed but is not consistent in it's quality or depth.