Register your product to gain access to bonus material or receive a coupon.
"IF YOU ARE THINKING about using UNIX, you must have this book."
The popular handbook --
now with a hypertext version for the Hyper-Impatient
UNIX for the Impatient is is an in-depth, comprehensive guide to UNIX -- a handbook you can use both for learning and as a ready reference. Clear, concise, and readable, the book is written for the technically oriented UNIX user who doesn't want to wade through verbose tutorials but isn't already an expert. Its functional organization makes it easy to find the right tool for any task, and an extensive discussion of underlying UNIX concepts, supplemented by a glossary, enables even a UNIX beginner to penetrate the mysteries of UNIX terminology.
UNIX for the Hyper-Impatient, on the accompanying CD-ROM, complements the printed book by giving you even more powerful ways to retrieve information quickly. The CD-ROM contains the entire text of the book, together with the DynaText hypertext system for navigating through it. The DynaText software will run on a variety of UNIX systems (with Motif)*, as well as on Microsoft Windows and Macintosh. Valuable features include links for retrieving the syntax and options of any UNIX command as well as its full description; a dynamically expandable table of contents; links for tracing cross-references; search operations over either section headings or the entire text using combinations of terms, phrases, nearby words, or wildcards; facilities for the reader to add personal annotations and hyperlinks; and the ability to save or print excerpts of the book. The CD-ROM also includes the Slackware distribution of Linux, a free but thoroughly professional version of UNIX, and the full set of files for the Emacs editor.
This up-to-date and practical work is based on the IEEE POSIX.2 Standard now widely adopted by UNIX vendors and implementors. Important System V, BSD, and GNU variations and enhancements are also presented. Topics include user utilities, shells, the vi editor and other standard editors, the GNU Emacs editor, Internet access tools, the awk language, the X Window System, and system administration from the user's perspective.
Linux version of the DynaText browser not yet available.
0201419793B04062001
1. Introduction.
UNIX Background.
The POSIX.2 Standard.
How to Use This Book.
Typographical Conventions.
Syntactic Conventions.
Getting Started.
The UNIX Manual.
System Administration and the Superuser.
Users and Groups.
What the Shell Does.
The UNIX Kernel.
Processes.
The UNIX File System.
File Permissions.
Conventions for Using Files.
Standard Files and Redirection.
Other Facilities for Interprocess Communication.
UNIX Commands.
Local Variables.
Initialization Files.
Terminal Descriptions.
Locales, Code Sets, and Internationalization.
Regular Expressions.
Devices.
Operations on Directories.
Listing Files with ls.
Displaying and Concatenating Files with cat.
Linking, Moving, and Copying Files with ln, mv, and cp.
Removing Files.
Examining Files or Output with a Pager.
Printing Files.
Finding Files with find.
Locating, Classifying, and Checking Files.
Comparing Files.
Controlling File Access and Ownership.
Miscellaneous File Utilities.
Data Compression and Encoding.
Archiving Sets of Files.
Examining Files with od.
Copying and Converting Data with dd.
Updating Files with patch.
Creating Special Files.
Sorting Files with sort.
Finding Patterns with grep.
Simple Data Transformations.
Extracting Parts of Files.
Combining Files.
Using sed to Edit from a Script.
The awk Programming Language.
Other Data Manipulation Languages.
Information Services.
Reporting on the Status of Processes.
Managing Processes.
Commands Related to Logging In.
Controlling Your Terminal.
On-Line Communication with Other Users.
Disk Usage Statistics.
Writing and Reading Strings.
Evaluating Expressions.
Special Invocation of Commands.
Querying Your UNIX Environment.
Miscellaneous Services.
Producing Locale Information and Defining a Locale.
Document Processing.
Version Control.
Overview of the KornShell.
Interacting with the Shell.
Editing an Input Line.
Calling the Shell Directly.
Shell Scripts.
Syntax of Shell Input.
Patterns.
Simple Commands.
Linking Commands with Operators.
Redirection.
Here-Documents.
The test, true, and false Commands.
Compound Commands.
How Commands Are Executed.
Parameters.
Parameter Expansions.
Quotation.
Substitutions.
Aliases.
Commands for Job Control.
The Command History and the fc Command.
Intrinsic Commands and Predefined Aliases.
Predefined Variables Used by the Shell.
Execution Options.
Initialization Files for the Shell.
Parsing Command Lines with getopts.
A Sample Shell Script.
The C Shell csh.
Bash, the “Bourne-again Shell.”
The vi Visual Editor.
Local Variables for vi and ex.
The Extended Editor ex.
The ed Line Editor.
Tag Files.
Calling and Terminating Emacs.
Conventions for Typing Input.
Getting Acquainted with Emacs.
Emacs Concepts.
How to Issue Commands.
Getting Help.
Exiting from or Suspending Emacs.
Basic Editing Commands.
Mouse Operations on Text.
Additional Editing Commands.
Indentation.
Operations on Rectangles.
Operations on Windows.
Operations on Frames.
Operations on Files.
Explicit Operations on Buffers.
The Buffer Menu.
Printing.
Registers and Their Operations.
Searching and Replacing.
Operations on Variables.
Evaluating LISP Expressions.
Executing UNIX Commands from Emacs.
Environmental Inquiries.
Customizing Emacs.
Directory Operations with Dired.
Composing and Editing Pictures.
Tags and Tag Tables.
The Emacs Mailer.
The GNUS Newsreader.
The Calendar.
The Diary.
The Version Control Interface.
Amusements.
What’s in a Message?
Recipients.
Mailboxes.
Forwarding Mail.
The mailx (Berkeley Mail) Mailer.
Other Mailers.
Archiving Files for Mailing with shar.
Newsgroups and Newsreaders.
UNIX Newsreaders.
Network Addresses.
Local-Area Networks.
Distributing Files Over Networks.
Internet Resources.
Programs for Remote Communications.
Remote Operations on “Nearby” Computers.
Calling a Remote Computer with telnet.
Transferring Files Between Computers with ftp.
File Transfers Based on uucp.
Connecting to Remote Computers with cu.
The X Screen.
Getting Started and Quitting.
Window Managers.
Servers, Displays, and Display Specifications.
Widgets.
Properties.
Command-Line Options for X Applications.
Resources and Their Specifications.
The Resource Database.
Geometry Specifications.
Fonts.
Colors.
Initialization Files for X.
The xterm Terminal Emulator.
Informational Displays for X.
Color and Font Information for X.
Clients for Initializing and Customizing X.
Killing an X Client with xkill.
Viewing Manual Pages with xman.
Running with Superuser Privileges.
System Administration Programs.
Explicit System Administration.
Software Installation.
File System Maintenance.
Startup and Shutdown.
List of Commands.
Summary of Commands and Features.
Treatment of Files.
MS-DOS Commands and Their UNIX Equivalents.
Other Related Features.
Books.
CD-ROMs.
UNIX for the Impatient is a UNIX handbook--a detailed, comprehensive guide to the UNIX system that can serve both as a ready reference and as a means of learning UNIX. We've consciously aimed the book at readers who are comfortable with technical material, presenting the subject as concisely as possible rather than in gentle but lengthy tutorial steps and covering in a section what other authors cover in a volume. We achieve that not by omitting details but by omitting long explanations and numerous examples that illustrate a single point. Though the tutorial approach may be less demanding, ours is faster; thus the title of our book.
UNIX has become the standard operating system for computers in scientific, engineering, and research environments. Designed to be used interactively, UNIX is not bound by inherent memory constraints, handles multiple processes and users easily and naturally, and is well suited as a platform for networking and graphical environments. As the only major operating system not irrevocably tied to a specific hardware architecture, UNIX is particularly well adapted to use in networks of heterogeneous computers. Most UNIX systems now support the graphical user interface provided by the X Window System and most UNIX users use that interface. The result is that UNIX is now as easy and comfortable to use as any of the other graphics-based systems such as Microsoft Windows that are available on workstations and personal computers.
Commercially supported versions of UNIX have long been available for most computers, but their price has usually been prohibitive for individual users. High-quality free systems that run on personal computers are now widely available as well. The advent of those free systems, Linux in particular, has enormously broadened the population of UNIX users.
The POSIX.1 standard for UNIX-like system calls has been widely accepted for several years and has enabled programmers to write portable UNIX programs. The newer POSIX.2 standard for user commands, the standard on which this book is based, has meant that UNIX systems from different sources and on different computers have become more consistent with one another. Additional POSIX standards under development promise to make it even easier to move among UNIX systems.
But UNIX is not an easy system to learn. In the early days of UNIX when it was still a research project, one person could master all its details and even a casual user could master most of them. That is true no longer. Today's UNIX user faces great obstacles: the profusion of commands and their options, variables, and subcommands; the differences among implementations; the rapid pace of change; the proliferation of related subsystems such as the Network File System and the X Window System; the sheer volume of material to be assimilated; the historical accretions; and the assumption all too prevalent in UNIX documentation that the reader is already familiar with what is being described.
Technically sophisticated people often prefer to learn new programs and computer systems by reading the reference manuals, but it's hard to learn UNIX that way. The traditional UNIX reference manual consists of an alphabetical list of command descriptions called "manual pages". Many manual pages are cryptic, misleading, poorly organized, or erroneous in subtle ways. UNIX-specific terminology is often used without being defined; terminology is often used inconsistently from one command to another. The customary alphabetical list of options makes it difficult to see how the options relate to one another. Few manuals provide an overview or explanation of the basic UNIX concepts, and those that do often rely on early technical papers that are now about two decades old and cannot reflect what has happened since they were written.
The central purpose of UNIX for the Impatient is to serve as a better manual for people who like to learn from manuals. We tell you about those undocumented, confusing, or subtle aspects of UNIX commands that a reading of the manual pages is unlikely to reveal. Rather than lead you by the hand through UNIX, we assist you in finding your own way. If you're seeking an easier but slower route to learning how to use UNIX, we suggest getting started with tutorial books (you may need several) and then turning to UNIX for the Impatient as you progress.
We describe UNIX from the standpoint of a user; that is, a person primarily interested in it as a tool rather than as an object of study for its own sake. Much of the book consists of command descriptions, usually as detailed as the ones in your system's manual. An important difference between our book and your manual is that we've organized the book and its parts, including the descriptions of the commands, logically by function rather than alphabetically. The functional arrangement enables you to see how different commands and options relate to one another, making it easier to find the right tools for a particular task. We include an alphabetical summary of commands and their options cross-referenced to the pages where you'll find the full descriptions. You can use the alphabetical summary both to get a quick reminder of what a particular command or option does and to retrieve the full description. The synopsis preceding the table of contents provides a fast overview of everything in the book, and we have paid particular attention to providing a thorough index.
In the second chapter of the book we cover the essential concepts of UNIX such as processes, files, shells, regular expressions, pipes, and redirection. These concepts underly the detailed descriptions in the rest of the book. We also provide a glossary containing concise definitions of UNIX terminology. When you encounter a technical term that you haven't seen before, you can easily find out what it means. We provide abundant cross-references to help you through the thicket of dependencies among different UNIX commands and concepts. To get you oriented, we provide a discussion of how to use this book in Section 1.3.
In keeping with our orientation of UNIX for the Impatient as a book primarily for users, we don't generally say much about UNIX internals--those aspects of UNIX mainly of interest to system programmers--although if you're a system programmer, this book can still be helpful for dealing with the external aspects of UNIX. Nor do we attempt to describe the programming facilities of UNIX such as the C compiler, lex,and yacc. How to use these tools, particularly C, can occupy a book by itself.
We do, however, describe awk
, which is relatively easy to learn and which provides an easy way of transforming and filtering data while enabling you to carry out fairly complex programming tasks. In a few places, such as our discussions of awk and of shell scripts, we assume some familiarity with programming methods and terminology--we couldn't avoid it--but most of the book can be understood even if you aren't familiar with programming.
UNIX has become what it is today more through accretion than through conscious planning. There's a principle of programming language design called "orthogonality"--the idea that different aspects of the language interact as little as possible and can be treated independently. UNIX, unfortunately, violates that principle egregiously. Programs are sensitive to the conventions of other programs and interact with each other in complex ways. For example, the vi
visual editor was built on top of the ex
extended line editor, so-called because it extended the earlier ed
editor. Thus to understand vi
fully you also must know ex
even though you have no interest in ex
for its own sake.
Moreover, many UNIX facilities are someone's improvement or elaboration on an existing facility. The old version persists even when the new version is indisputably better. Programs with overlapping functions are common. Thus there are three data compression programs, pack
, compress
,and gzip
; at least two different mail programs that call themselves mail
; and several programs for splitting files into segments, head
, tail
, split
, csplit
, and dd
. There are at least four widely used shells for managing interaction with your terminal: the KornShell ksh
, the Bourne shell sh
,the Cshell csh
, and Bash, the GNU "Bourne-again Shell".
This profusion of similar facilities created a dilemma for us. How many of these programs should we try to cover? We have chosen to describe nearly all the utility commands despite their overlapping functions. On the other hand, we have based our discussion of shells in general on the KornShell, since that shell includes nearly all the facilities found in the others. We supplement that discussion by a description of the features of the other shells where they differ from the KornShell.
British lorries roll on tyres, while American trucks roll on tires. Just as there are many dialects of English, there are many versions of UNIX. Fortunately the POSIX.2 standard has brought a measure of consistency to the UNIX world; most implementors now adhere to it. But major differences among systems persist, particularly between System V-based systems and BSD-based systems. The POSIX specifications for some commands such as man and ps are deliberately skeletal, recognizing that the differences among existing implementations are too great to be bridged. Most systems provide additional commands beyond those specified by POSIX and additional options for the commands that are specified by POSIX. Pre-POSIX systems such as Solaris 1.x are still widely used, and pre-POSIX commands are still often found in otherwise POSIX-conforming systems.
The command descriptions in the Second Edition of UNIX for the Impatient follow the POSIX standard. However, we note many important variations and include a number of commands that are not part of POSIX. For example, we describe both the POSIX lp
command for sending files to a line printer, derived from the System V command of the same name, and the BSD lpr command that does nearly the same thing but does it differently. You may find that some commands don't work on your system exactly as we describe them, but the differences will usually be minor.
You'll find topics covered in this book that don't make it into most UNIX books. Some examples are the X Window System, the emacs
editor, communications programs such as telnet
and ftp
, the addressing conventions used for Internet and UUCP electronic mail, and popular but nonstandard utilities such as the gzip
compression program and the shar
archiver for sending files via electronic mail. Although we hope this book is the first one you take off the shelf, we realize it may not be the last, so we provide a list of printed and electronic resources you can use for additional information or for another view of the same material.
Our approach to UNIX is like Albert Einstein's approach to physics: make it as simple as possible, but no simpler. We explain UNIX as clearly as we can without neglecting difficult or complicated, but nevertheless essential, details. While some of these details may not seem important when you first see them, you're likely to find them indispensable as you read the manuals supplied with your system.
For those who notice such things, we mention that we've adopted the British (logical) treatment of punctuation at the end of a sentence: when a quotation ends a sentence, we place the period outside the quotation. We consider this policy necessary for any book whose subject matter demands great orthographic precision. We appreciate the indulgence of our editors.
Some people use UNIX by choice, others by necessity. We hope UNIX for the Impatient will be useful to you whatever your view of UNIX may be.
The Second Edition of UNIX for the Impatient reflects both the dramatic changes in the UNIX world from 1991 to 1995 and changes in our own understanding of how we as authors can best meet the needs of our readers. The world of commercial UNIX has been profoundly affected by AT&T's sale of UNIX Systems Laboratories (USL) to Novell, Inc., and by the refinement and general acceptance of the POSIX standards. High-quality free systems such as Linux and FreeBSD, complete with source code unaffected by USL licensing restrictions, have appeared, at last making UNIX affordable and available to individual users. The scope of the software components found in the GNU collection from the Free Software Foundation has broadened and the components themselves have matured; some of these components are now used in nearly every UNIX installation. The number of Internet users, the services available through the Internet, and the number of Internet service providers have all multiplied prodigiously to the point where "Internet" is now a household term and great numbers of people access the Internet as individuals, not as members of some organization.
In the First Edition we used System V as the base for our description of UNIX's facilities; in the Second Edition we use the POSIX.2 standard. This shift has led us to introduce descriptions of additional commands and has brought about many and pervasive textual revisions, including changes in terminology to be consistent with POSIX. Following the practice in the POSIX standard, we have replaced most generalized references to "options" in the syntax of commands with lists of the specific options each command accepts.
Because POSIX has already been widely adopted and POSIX conformance by UNIX vendors is increasing, you are now likely to find fewer differences between the features we describe and the ones you find in your particular version of UNIX. Nearly all the purely syntactic changes specified by POSIX are for the sake of greater uniformity and consistency. These changes have made the UNIX command interface much easier to use.
We have greatly expanded the number of commands we cover. The Second Edition describes all the POSIX user-level commands except for a few specifically intended for programmers: ctags
and nm
from the User Portability Utilities and ar
, make
,and strip
from the Software Development Utilities. We have, however, retained our brief discussion of tag tables from the First Edition, and the material on software installation includes a discussion of makefiles from the user's viewpoint. We have also added some widely used non-POSIX commands such as gzip
and shar
.
It would take a separate book to provide anything like an adequate guide to the Internet, and indeed a number of such books have already been written. In this book we have expanded our Internet coverage to include the World Wide Web and other tools for exploring the riches of the Internet. We also include an explanation of USENET newsgroups and the newsreader programs used to access them.
Version 19 of Emacs is fully integrated with the X Window System and has many new and enhanced features. We have expanded our coverage of Emacs and have divided our treatment into two parts: a chapter on the editing facilities proper and another on Emacs's rich set of utilities, utilities such as the Directory Editor, the Mailer, and the Outliner.
The Bourne shell sh has largely been superseded as a user-level shell, even though it still provides a base set of facilities useful for writing shell scripts intended for general distribution. We have replaced its description by a description of the KornShell ksh
, which provides a superset of the shell facilities specified by POSIX and also of those in the Bourne shell. We note those features of the KornShell that are not supported by the POSIX shell or the Bourne shell. We have folded our description of the C shell into the description of the KornShell and have added material on Bash.
As use of UNIX has spread beyond its American origins, internationalization has become essential to many UNIX users. The POSIX standard provides locales and other features that make UNIX suitable for international use. We have added a section on internationalization to the Concepts chapter and have modified the descriptions of UNIX facilities to account for the new POSIX features.
The brief section on "System Administration for Single-User Systems" has been moved and expanded into a full chapter, "Managing Your System". The new chapter covers important system files such as those usually found in the /etc
directory and programs such as mount
, lpd
, and init
that provide administrative services. It also explains how to install new software, particularly in the usual case where the software has been distributed in the form of source code. While intended primarily for readers who are running single-user systems for themselves, the new chapter should be helpful to users of larger systems who wish to understand what is going on within those systems or need to install software from an outside source. It will also assist anyone attempting to decode the frequent references to these files and programs in the UNIX literature.
UNIX for the Hyper-Impatient is a hypertext version of UNIX for the Impatient, distributed on a CD-ROM. The idea of it came from Lisa Richards of QuickScan Electronic Publishing, who pointed out that a book such as this one is a natural candidate for a hypertext form because there are so many cross-references from one part to another. UNIX for the Hyper-Impatient is included in the CD-ROM version of this book and is also available separately.
UNIX for the Hyper-Impatient contains the entire text of UNIX for the Impatient, together with the DynaText browser developed by Electronic Book Technologies of Providence, Rhode Island. The primary view of the book contains two windows, one showing the Table of Contents and the other the text of the book. Using the Table of Contents, which you can expand or collapse, you can select any part of the book and scroll through the text starting there.
Wherever there's a cross-reference in the printed book, there's a hyperlink in the hypertext version. By clicking your mouse on that hyperlink, you can jump directly to the cross-referenced text, then easily return to where you were before. You can also check out all the index references to a topic by going to the index entry, then looking at the references one by one. Footnotes and figures don't interrupt the flow of the text; you view them by clicking on an icon that appears where the footnote or figure is referenced. You can also search either the entire book or just the headings, using a variety of search specifications.
Information about the features of the DynaText browser and how to use the CD-ROM is provided in the shaded pages at the end of the CD-ROM version of the printed book and in the booklet that accompanies the separately packaged version of UNIX for the Hyper-Impatient.
Deerfield, Massachusetts
P.W.A.
Milton, MAssachusetts
B.R.L.