Previous Table of Contents Next


Each file has one inode number that points to that file's index node, or inode for short. A file has one and only one inode, even though it may have multiple filenames. The filenames are all linked to the same inode by the directory entries. An inode contains the following information:

owner (user ID)
type (directory, ordinary, block special, character special, or pipe)
access permissions (user, group, others)
access times (last modification, last access, last inode modification)
number of links size in bytes (number of filenames stored in directories)
disk addresses (Multiple entries point to the data of which
- some entries point to data blocks
- other entries point to a single indirect block
- other entries point to a double indirect block
- other entries point to a triple indirect block)

Limitations

The current limit on a file size is over 4 gigabytes, based on 1024-byte file system blocks, usually more space than is available on the entire system's disk drives. The name of a file can only be 256 characters.

Problems

On a multiuser system with thousands of files, there is the possibility that the filename has been used previously by another user. This does not pose a large problem, because most users have their own private directories, but it must be considered in publicly used directories.

SPECIAL FILES

Special UNIX files are pieces of computer code that interface with the UNIX kernel. There are two types of special files: device drivers and fifos. Both are interfaces within the UNIX kernel, a part of the I/O subsystem.

Device drivers are used to communicate with and control peripheral devices attached to your UNIX System, such as printers, terminals, disk drives, or tape drives. Device drivers may be block or character special, referring to how the driver handles I/O to and from a device.

Fifo (Pipes) are used to join two or more UNIX processes together allowing the streaming of data. Streaming data means that data flows from one program into the next without being stored on disk. Fifo special (first-in first-out), or named pipes, allow unrelated UNIX programs to exchange information.

Device Drivers

Device drivers are block or character special files. They are low-level routines that reside in the system kernel where they interface to peripheral devices, such as terminals, printers, disk and tape drives, connected to the computer system. They perform I/O tasks to and from a specific type of device. UNIX device drivers are interfaces that make devices appear as ordinary files when performing I/O functions.

Block-type drivers read and write in blocks of data, resembling random access storage. A block is usually 512 or 1024 bytes, depending on your system's BSIZE constant stored in /usr/include /sys/param.h.

Character-type drivers read and write a single byte of data, often referred to as raw devices. Most of the device drivers on a UNIX System are character special.

Pipes

A pipe is a UNIX file that takes the output of one process and provides it as input to the next process. A more internal view of a pipe would be that data is transferred between processes in a first-in first-out sequence. The pipe also synchronizes the execution of the surrounding processes. The first process must execute and begin output before the next process can begin its execution.

The most common use of pipes is to connect multiple UNIX programs together to form a pipeline. A pipeline feeds information from one program to the next.

When executing multiple UNIX commands, pipes may be used between the commands to create what is referred to as a pipeline command. Likewise, if data is to start in an original state at the source and be manipulated by commands along the way to its destination, then pipes must be used to connect the commands together so that the data flows to the destination. For convenience, the entire command is called a pipeline.

Since the commands are changing the data along the way, they are referred to as filters. A command must be capable of being a filter for it to be used in a pipe. A filter can read from standard input and write to standard output. The pipe passes data unchanged while a filter manipulates the data as it is passed down the pipeline.

Enter the following command at your shell prompt and press Return:

   cj> grep :0: /etc/passwd | nawk -F: '{ print $1 " "$5}' | sed 's/:/<TAB>/g'
   root      Admin. - super user
   sync      File system sync
   dgn       Diagnostics

The output is the first and fifth fields of lines from the password file that contained the :0: string, which should be all logins with root user ID permissions.

The same results could have been accomplished using temporary files, but this is very inefficient and clumsy.

   cj> grep :0: /etc/passwd > TMP1
   cj> nawk -F: '{ print $1 " " $5 }' TMP1 > TMP2
   cj> sed 's/:/<TAB>/g' TMP2
   root      Admin. - super user
   sync      File system sync
   dgn       Diagnostics
   cj> rm TMP1 TMP2

THE UNIX SHELL

The shell (ksh) is a very powerful and dynamic UNIX utility that functions as the UNIX command interpreter. It is the primary user interface to the operating system (kernel). The shell is a command language and a programming language. As a command language it can be used to communicate interactively with the kernel. As a programming language users can write shell scripts to solve simple to complex problems.

The shell is probably the most sophisticated UNIX utility. It can read from your terminal or from a file. Thus is can be interactively programmed or programs can be stored in files.

The following is a typical sequence of events when a user interacts with the shell as the primary user interface:

1.  User logs in to the system.
2.  The shell prompts for input (a command).
3.  User types in command and presses Return.
4.  The shell searches for program; if found, executes it.
5.  Program runs; user may interact with program.
6.  Program exits; user may have to exit the program.
7.  The shell prompts for next command; return to number 4 above.
8.  User types exit, logout, or Ctrl-D to exit shell.
9.  The shell logs the user off the system.

Modules 71 and 23 include detailed looks at the shell as a command language. Module 108 is a detailed look at the shell as a programming language.

SYSTEM DOCUMENTATION

There are many different documents produced by AT&T and other UNIX developers. The primary documents for each UNIX System are the Reference Manuals and Guides. These documents provide you with specific details on the UNIX System you are using. One other document that most users ignore but that is extremely important is the Release Notes for UNIX and all related software. Release Notes provide insight to changes, quirks, problems, and compatibility issues relating to the new release of the software. It will be to your benefit to locate a copy and discover what your release of UNIX holds in store for you.

The User's Reference Manual and the User's Guide describe the basic utilities and software of the UNIX System. The Reference Manual describes each utility that is available on the UNIX System. The Guide provides an overview and tutorials on the more common and complex UNIX utilities.

Illustrated UNIX addresses both of these areas to provide a tutorial and a reference manual in one book. It demystifies the guru language of the standard reference manuals and organizes the tutorials into a useful sequence that can later be easily referenced.

Turn to Module 71 to continue the learning sequence.


Previous Table of Contents Next