Полезная информация

TOC Next Page Home


Sams Development Team

SAMS Publishibng

201 West 103rd Street, Indianapolis, IN 46290

Copyright © 1994 by Sams Publishing


All rights reserved. No part of this book shall be reproduced, stored in a retrieval system, or transmitted by any means, electronic, mechanical, photocopying, recording, or otherwise, without written permission from the publisher. No patent liability is assumed with respect to the use of the information contained herein. Although every precaution has been taken in the preparation of this book, the publisher and author assume no responsibility for errors or omissions. Neither is any liability assumed for damages resulting from the use of the information contained herein. For information, address Sams Publishing, 201 W. 103rd St., Indianapolis, IN 46290.

International Standard Book Number: 0-672-30402-3

Library of Congress Catalog Card Number: 93-86957

97 — 96 — 95 ————————— 4 — 3 — 2

Interpretation of the printing code: the rightmost double-digit number is the year of the book's printing; the rightmost single-digit, the number of the book's printing. For example, a printing code of 94-1 shows that the first printing of the book occurred in 1994.

Printed in the United States of America


All terms mentioned in this book that are known to be trademarks or service marks have been appropriately capitalized. Sams Publishing cannot attest to the accuracy of this information. Use of a term in this book should not be regarded as affecting the validity of any trademark or service mark.

UNIX is a registered trademark of UNIX System Laboratories, Inc.


Richard K. Swadley

Associate Publisher

Jordan Gold

Acquisitions Manager

Stacy Hiquet

Managing Editor

Cindy Morrow

Acquisitions Editors

Grace Buechlein
Chris Denny
Rosemarie Graham

Development Editors

Kristi Hart
Scott Parker

Software Development Specialist

Wayne Blankenbeckler

Senior Editor

Sandy Doell


Marla Abraham
Susan Christopherson
Fran Hatton
Greg Horman
Charles Hutchinson
Carolyn Linn
Sean Medlock
Rosie Piga
Andy Saff
Angie Trzepacz
Kitty Wilson

Editorial Coordinator

Bill Whitmer

Editorial Assistants

Carol Ackerman
Sharon Cox
Lynette Quinn

Technical Reviewers

Tim Parker
Mark Sims
Dave Taylor
Sandra Tucker

Marketing Manager

Gregg Bushyeager

Cover Designer

Nathan Clement

Book Designer

Alyssa Yesh

Director of Production and Manufacturing

Jeff Valler

Imprint Manager

Juli Cook

Manufacturing Coordinator

Paul Gilchrist

Production Analysts

Dennis Clay Hager
Mary Beth Wakefield

Graphics Image Specialists

Teresa Forrester
Clint Lahnen
Tim Montgomery
Dennis Sheehan
Greg Simsic
Susan VandeWalle
Jeff Yesh

Page Layout

Elaine Brush
Rob Falco
Ayanna Lacey
Stephanie J. McComb
Chad Poore
Casey Price
Kim Scott
Susan Shepard
Scott Tullis
Dennis Q. Wesner


Carol Bowers
Georgiana Briggs
Don Brown
Mona Brown
Ayrika Bryant
Michael Brumitt
Cheryl Cameron
Elaine Crabtree
Michael Dietsch
Rich Evers
Kimberly K. Hannel
Jamie Milazzo
Brian-Kent Proffitt
SA Springer
Robert Wolf


Jeanne Clark
Bront Davis
Greg Eldred
Johnna VanHoose

About the Authors

Susan Peppard was born many years ago in New York City. She attended New York University where she studied French literature and picked up a couple of degrees. When this failed to produce splendid job offers, she turned to computers (big, blue, room-sized machines, sporting 30 KB of memory).

Today, 30 years later, she confines her computer-related activities to writing on and about them and playing games. She is a documentation consultant (technical writer) and lives in New Jersey with a horrible black dog, an innocuous grey cat, and—between semesters—varying configurations of her children. She and UNIX met in 1985 and have been living together happily ever since.

Pete Holsberg saw his first computer in 1960, as a graduate student at Rutgers, and they have plagued him ever since. While at Rutgers, he was exposed to both analog and digital computers. He went to work for Electronic Associates, Inc., Princeton, New Jersey on leaving Rutgers. EAI was the world's largest manufacturer of analog and hybrid computers.

He later joined Mercer College, Trenton, New Jersey in 1970 as associate professor of electrical engineering and was given responsibility for the PDP-8/I lab. He was instrumental in bringing microcomputers to the campus in 1981; these were used in electronics engineering technology education. Currently, he is systems administrator for the college's UNIX lab, consultant to the college's Academic Computing Committee, secretary of the college's LAN Computing Committee, advisor to the Educational Technology Users Group for faculty and staff, and coordinator for electronics curricula.

Pete has authored a textbook on C for electronics engineering technology for Macmillan and a book on UNIX tools for Macmillan Computer Publishing. He has written invited chapters in a number of MCP books, and has been the technical editor or technical reviewer for many of MCP's UNIX book offerings.

Pete lives in Ewing, New Jersey with his wife, Cathy Ann Vandegrift and their four computers. They sail and enjoy the New Jersey Symphony Orchestra. Pete has a private pilot's license and is an avid autocross racer and tennis hacker. Cathy is a Realtor.

James C. Armstrong, Jr., is a software engineer with ten years of industry experience with UNIX and C. He is currently working as a technical editor at Advanced Systems, and also works free-lance for several other companies in the San Francisco Bay area. He can be reached at james@sagamartha.com.

Salim M. Douba is a network consultant with Proterm Data Systems Ltd./USConnect, Ottawa, Ontario, Canada. He is also an independent certified NetWare Instructor (CNI) teaching NetWare operating systems and advanced courses. He holds a master's degree in electrical engineering from the American University of Beirut. His experience and main career interests have primarily been in Internetworking and multiplatform integration. He is reachable on CompuServe on 70573,2351.

S. Lee Henry writes a systems administration column for SunExpert Magazine, and manages systems and networking for the physics and astronomy department at Johns Hopkins University. She is on the board of directors of the Sun User Group and has been a UNIX programmer and administrator for over twelve years.

Ron Rose is an international management consultant with 20 years of data processing management experience. He has led large-scale data processing installations in Asia, Europe, and the United States, and he has managed several software product start-up efforts. He completed a master's in information systems from Georgia Institute of Technology, after completing undergraduate work at Tulane University and the University of Aberdeen, Scotland. His current position is as a director for Bedford Associates, Inc., in Norwalk, Connecticut, where he leads groups that provide Open Systems and Lotus Notes products, along with related high-performance UNIX systems-integration work. He also has appeared on national television (CNBC) as a management consultant on technology issues.

Richard E. Rummel, CDP, is the president of ASM Computing, Jacksonville, Florida, which specializes in UNIX software development and end user training. He has been actively employed in the computer industry for 20 years. Married for 21 years, he is the father of two children, a dog, and a cat.

Scott Parker has worked as a UNIX system administrator and an ORACLE Database administrator and developer for several companies.

Ann Marshall is a UNIX computer professional specializing in relational database management and system administration. A free-lance writer in her spare time, she has written articles about the RS/6000 in RS/Magazine. She received her undergraduate degree in economics and English from Vanderbilt University and obtained her master's degree in computer science from the University of Alabama in Huntsville. Outside of computers, Ann's hobbies include travel, reading, and writing fiction. You can reach Ann on CompuServe at 71513,335.

Ron Dippold graduated from Rose-Hulman Institute of Technology with a degree in electrical engineering and computer science. He is employed as a senior engineer at Qualcomm, Inc., of San Diego, CA. He is the author of several computer books and is a technical editor for many more. He served as a computer columnist and consulting editor for ComputerEdge Magazine.

When Chris Negus isn't playing soccer or listening to Indigo Girls, he's usually writing about UNIX. Despite contributions to dozens of books and articles on UNIX, he still maintains that he is not a geek. In the past decade, Chris has worked for AT&T Bell Laboratories, UNIX System Laboratories, and Novell as a UNIX consultant. He most recently coauthored Novell's Guide to UNIXWare for Novell Press. Presently, Chris is a partner in C & L Associates, a UNIX consulting company in Salt Lake City.

John Valley lives in Richmond, Virginia with his wife Terri and his Labrador retriever, Brandon. Mr. Valley currently operates a small practice as an independent consultant for UNIX and Windows tools and applications. With more than twenty years of experience in the computer industry, his background ranges from Cobol business applications and mainframe operating system development to UNIX tools and Windows programming. He teaches courses in C/C++ programming and UNIX fundamentals.

Mr. Valley is largely self-taught, having started as a night shift computer operator in 1972. After serving time as a Cobol applications programmer and mainframe systems programmer, he signed on with Nixdorf Computer Software Corporation (now defunct) to write operating system code. Soon promoted to project leader, he supervised the company's product design efforts for four years. Almost by coincidence, he encountered the UNIX environment in 1985 and quickly became a devotee of UNIX and C programming.

He has published three books on UNIX topics: UNIX Programmer's Reference (Que; 1991), UNIX Desktop Guide to the Korn Shell (Hayden; 1992), and C Programming for UNIX (Sams; 1992).

Jeff Smith is a psychology major who took a wrong turn and ended up working with computers. Jeff has worked with UNIX systems since 1982 as a programmer and systems administrator. He has administered mail, news, security, and the domain name system on several varieties of UNIX including 2.9BSD, 4.3BSD, Dynix, SunOS, and AIX. Currently, he manages a network of 180 Sun workstations at Purdue University.

Dave Taylor has been working with UNIX since 1980, when he first logged in to a Berkeley-based DEC VAX computer while an undergraduate at the University of California, San Diego. Since then, he's used dozens of different UNIX systems and has contributed commands incorporated into HP's HP-UX UNIZ operating system and UC Berkeley's BSD 4.4 UNIX release. His professional experience includes positions as research scientist at Hewlett-Packard Laboratories in Palo Alto, California; software and hardware reviews editor for SunWorld Magazine; interface design consultant for XALT Software; and president of Intuitive Systems. He has published more than 300 articles on UNIX, Macintosh, and technical computing topics, and also the book Global Software, addressing the challenges and opportunities for software internationalization from a marketing and programming viewpoint. He is well-known as the author of the Elm Mail System, the most popular screen-based electronic mail package in the UNIX community.

Currently he is working as a consultant for Intuitive Systems in West Lafayette, Indiana, while pursuing a graduate degree in educational computing at Purdue University and working on a new interface to the FTP program.

Sydney S. Weinstein, CDP, CCP, is a consultant, columnist, lecturer, author, professor and president of Myxa Corporation, an Open Systems technology company specializing in helping companies move to and work with Open Systems. He has more than 15 years of experience with UNIX dating all the way back to Version 6. He is a contributing editor for C Users Journal and was a contributing author for UNIX Programmer's Reference (Que, 1990). He can be contacted care of Myxa Corporation, 3837 Byron Road, Huntingdon Valley, PA 19006-2320 or via electronic mail using the Internet/USENET mailbox syd@Myxa.com (dsinc!syd for those who cannot do Internet addressing).

Dave Till holds a master's degree in computer science from the University of Waterloo (a well-respected institution), majoring in programming language design. He also has substantial experience developing compilers and compiler technology, and has several years of technical writing experience.


by Scott Parker

Are you:

New to UNIX and looking for a book to help you get acquainted with UNIX?
Not so new to UNIX but looking to expand your knowledge?
A programmer looking for a guide to UNIX as a reference and a teaching guide for Perl, awk, and the shells?
A beginning system administrator looking to learn how to install UNIX or how to connect your UNIX to a network?
A system administrator looking for a reference guide or maybe just wanting to expand your knowledge?
A curious soul wanting to know everything about UNIX?

If any of these is true, you are holding the right book. UNIX Unleashed was written to cover all the bases. We started this book with the mission of giving you, the reader, a complete book on UNIX. In this book you will find

A tutorial for those who are new to UNIX. As you learn more about UNIX and get more and more comfortable, this book will be there to help you become a UNIX power user.
How to navigate the file system and how to use mail.
Instructive lessons on how to use vi, EMACS, sed.
How to program in the Bourne Shell, C Shell, and Korn Shell.
How to program in awk and Perl.
How to create your own man pages and formatted text.
How to install UNIX and power it down.
How to administer the file system, user accounts, the network, security system, mail, news, and devices.


Part I starts with a tutorial on "Finding Your Way Around UNIX." Robert and Rachel Sartin, Jeff Smith, Rick Rummel, Pete Holsberg, Ron Dippold and Dave Taylor give an introduction to operating systems. In Part I, you will find a step-by-step tutorial on how to log on the UNIX system and how to do some basic commands. There is also a complete introduction to all the file listing commands, file tools, and editing text files. You will also find a quick guide to navigating the network and methods to communicate with other systems on your network.

In Part II, "Hunt for Shells," Rick Rummel and John Valley teach you how to develop shell scripts for the Bourne Shell, Korn Shell, and C Shell.

In Part III, "Programming," Ann Marshall, David Till, and James Armstrong teach you how to program awk and Perl and how to use the UNIX C compiler.

In Part IV, "Process Control," Robert and Rachel Sartin give you an introduction to how to control your programs on UNIX. Here you find how to start a job (program) and how to kill it.

In Part V, "Text Formatting and Printing," James Armstrong and Susan Peppard give instruction on how to use these powerful macros, and how to create text with graphs, pictures, equations, etc. Learn how to create man pages and how to print postscript.

In Part VI, "Advanced File Utilities," Robert and Rachel Sartin and S. Lee Henry teach you how to put your programs or text into version control, how to back up and archive your work for protection against hard disk crashes, and more.

In Part VII, "System Administration," Sydney Weinstein, Chris Negus, Scott Parker, Ron Rose, Salim Douba, Jeff Smith, and James Armstrong teach the basics of UNIX System Administration. Here you will learn how to install UNIX, how to create user accounts, how to partition disk drives, and how to administer security, mail, uucp, and news.

Finally, in Part VIII, "UNIX Flavors and Graphical User Interfaces," S. Lee Henry and Kamran Husain give an overview of the history of UNIX and where it is going. You will learn how to navigate X Window and, for the more advanced, how to program in the GUI environment.

Part I Finding Your Way Around UNIX

1 — Operating Systems

2 —Getting Started: Basic Tutorial

3 — The UNIX File System—Go Climb a Tree

4 — Listing Files

5 — Popular Tools

6 — Popular File Tools

7 — Text Editing with vi, EMACS, and sed

8 — Getting Around the Network

9 — Communicating with Others

Part II Hunt for Shells

10 — What Is a Shell?

11 — Bourne Shell

12 — Korn Shell

13 — C Shell

14 — Which Shell Is Right for You? Shell Comparison

Part III Programming

15 — Awk, Awk

16 — Perl

17 — The C Programming Language

Part IV Process Control

18 — What Is a Process?

19 — Administering Processes

20 — Scheduling Processes

Part V Text Formatting and Printing

21 — Basic Formatting with troff/nroff

22 — Formatting with Macro Packages

23 — Formatting Tables with tbl

24 — Formatting Equations with eqn

25 — Drawing Pictures with pic

26 — Creating Graphs with grap

27 — Writing Your Own Macros

28 — Tools for Writers

29 — Processing and Printing Formatted Files

Part VI Advanced File Utilities

30 — Source Control with SCCS and RCS

31 — Archiving

32 — Backups

Part VII System Administration

33 — UNIX Installation Basics

34 — Starting Up and Shutting Down

35 — File System Administration

36 — User Administration

37 — Networking

38 — UNIX System Accounting

39 — Performance Monitoring

40 — Device Administration

41 — Mail Administration

42 — News Administration

43 — UUCP Administration

44 — UNIX System Security

PartVIII UNIX Flavors and Graphical User Interfaces

45 — UNIX Flavors

46 — Graphical User Interfaces for End Users

47 — UNIX Graphical User Interfaces for Programmers

A — What's on the CD-ROM Disc


Given life by Turing Award winning Bell Labs computer scientist Ken Thompson at Murray Hill, N.J., in August 1969, UNIX spent its early years as a research curiosity. When I met up with Unix in the summer of '82, however, it already possessed the one characteristic that destined it to dominate a major chunk of the world's market for operating systems—portability. UNIX kicked off the era of open systems, the first wholesale paradigm shift in the history of computing, by being the first portable operating system.

Portability is so crucial because it symbolizes everything that open systems is about, and is the critical computing ingredient for the Information Age. You may hear people use the word primarily to talk about their applications that can run on more than one type of computer platform, but, at its highest level of abstraction, portability is much more. When you think about using standard network interfaces to pass data between different computers, that's portability of information; running applications across a range of devices from desktop to mainframe—or even supercomputer—is portability across scale; and the ability to swap out old technology for the latest technical advances without dramatically affecting the rest of your installation is portability through time. All this is necessary to support the extremely sophisticated levels of information malieability that corporations need to make the Information Age really work.

UNIX was always technically cool, advanced, insanely great, etc. So cool that Bell Labs began giving it away to colleges and universities in 1975 because they thought it would be a good recruitment tool—they believed graduate computer engineers would want to work at the place that produced such an elegant piece of technology. But UNIX's all-important portability didn't come about until 1977. Before that, UNIX's technical qualities alone had lured many Bell operating company department heads to Murray Hill, where they learned about UNIX from its small team of creators and began deploying it on Digital Equipment Corporation computers throughout the Bell System. By 1977, AT&T found itself buying a much larger percentage of Digital's annual output than seemed comfortable. (AT&T didn't want to be responsible for a precipitous drop in Digital's fortunes if it had to stop buying for any reason.) So that year, UNIX's creators ported UNIX for the first time, to a non-Digital computer whose only significant characteristic was that it was a non-Digital computer.

After that, UNIX was portable, and entrepreneurs ported it to new microcomputers like crazy. That's when I came on the scene, as a computer industry news reporter covering all that entrepreneurial energy. Even in 1982, the manifest destiny felt by the people in the UNIX industry was clear. And the idea of a common operating system atop different hardware platforms so powerfully fired the imaginations of information systems managers in major corporations that, today, UNIX has become their de facto server operating system.

Given that you've purchased or are considering this book, you already know that UNIX is ubiquitous. What UNIX is not, however—even with the modern graphical user interfaces that paint a pretty face on it—is easy to program or administer compared to DOS or NetWare. Just as a 747 is a bit more complicated to run than, say, a glider, UNIX's increased flexibility and power come with the price of greater complexity.

This book, which delves deeply into the underpinnings of UNIX systems and offers detailed information on many different brands of UNIX , can be your first step on an enjoyable journey into the powerful, technically elegant world of open, portable computing.

Mike Azzara, associate publisher/editorial director, Open Systems Today.

TOC Next Page Home