Unix Unleashed UNIX UNLEASHED About the Authors Introduction Part I — Finding Your Way Around UNIX 1 — Operating System 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 — Networking with NetWare UNIX Unleashed Table of Contents http://docs.rinet.ru/UNIXy/ (1 of 3) [4/27/1999 10:45:14 AM] 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 UNIX Unleashed Table of Contents http://docs.rinet.ru/UNIXy/ (2 of 3) [4/27/1999 10:45:14 AM] 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 Part VIII — UNIX Flavors and Graphical User Interfaces 45 — UNIX Flavors 46 — Graphical User Interfaces for End Users 47 — UNIX Graphical User Interfaces for Programmers What's on the CD-ROM Disc What's on the Disc Add to Your Sams Library Today with the Best Books for Programming, Operating Systems, and New Technologies UNIX Unleashed Table of Contents http://docs.rinet.ru/UNIXy/ (3 of 3) [4/27/1999 10:45:14 AM] UNIX UNLEASHED Copyright © 1994 by Sams Publishing ■ Trademarks ■ About the Authors ❍ Introduction by Scott Parker ■ Organization ■ Foreword ■ ❍ ● UNIX UNLEASHED Sams Development Team SAMS Publishibng 201 West 103rd Street, Indianapolis, IN 46290 Copyright © 1994 by Sams Publishing FIRST EDITION 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 Trademarks 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. Publisher Richard K. Swadley UNIX Unleashed unxfmau.htm http://docs.rinet.ru/UNIXy/unxfmau.htm (1 of 10) [4/27/1999 10:45:29 AM] 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 Editors 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 UNIX Unleashed unxfmau.htm http://docs.rinet.ru/UNIXy/unxfmau.htm (2 of 10) [4/27/1999 10:45:29 AM] 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 Proofreading Carol Bowers Georgiana Briggs Don Brown Mona Brown Ayrika Bryant Michael Brumitt Cheryl Cameron Elaine Crabtree Michael Dietsch Rich Evers UNIX Unleashed unxfmau.htm http://docs.rinet.ru/UNIXy/unxfmau.htm (3 of 10) [4/27/1999 10:45:29 AM] Kimberly K. Hannel Jamie Milazzo Brian-Kent Proffitt SA Springer Robert Wolf Indexers 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 UNIX Unleashed unxfmau.htm http://docs.rinet.ru/UNIXy/unxfmau.htm (4 of 10) [4/27/1999 10:45:29 AM] 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 UNIX Unleashed unxfmau.htm http://docs.rinet.ru/UNIXy/unxfmau.htm (5 of 10) [4/27/1999 10:45:29 AM] 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. Introduction 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 UNIX Unleashed unxfmau.htm http://docs.rinet.ru/UNIXy/unxfmau.htm (6 of 10) [4/27/1999 10:45:29 AM] 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. Organization 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. UNIX Unleashed unxfmau.htm http://docs.rinet.ru/UNIXy/unxfmau.htm (7 of 10) [4/27/1999 10:45:29 AM] [...]... http://docs.rinet.ru/UNIXy/unxpt1au.htm [4/27/1999 10:45:45 AM] UNIX Unleashed unx01.htm q 1 — Operating System s s By Rachel and Robert Sartin What is an Operating System? s Hardware Management, Part 1 s Process Management s The UNIX Operating System s The History of UNIX s s s The Early Days Berkeley Software Distributions UNIX and Standards s s UNIX for Intel Platforms s Source Versions of "UNIX" s s UNIX for... two components are what many users think of as UNIX, because together they constitute the UNIX interface Figure 1.2 The layers of UNIX http://docs.rinet.ru/UNIXy/unx01.htm (3 of 9) [4/27/1999 10:45:56 AM] UNIX Unleashed unx01.htm The part of UNIX that manages the hardware and the executing processes is called the kernel In managing all hardware devices, the UNIX system views each device as a file (called... on your desk You just turn it on and type away UNIX workstations are similar to personal computers A UNIX workstation might have a floppy drive, a hard disk, and a very large monitor On a larger UNIX system, you might just have a terminal Large UNIX systems allow multiple logins http://docs.rinet.ru/UNIXy/unx02.htm (1 of 17) [4/27/1999 10:46:11 AM] UNIX Unleashed unx02.htm at a time In these situations,... detail The majority of UNIX users need to be familiar with the interface and need not understand the internal workings of UNIX The UNIX system is actually more than strictly an operating system UNIX includes the traditional operating system components In addition, a standard UNIX system includes a set of libraries and a set of applications Figure 1.2 shows the components and layers of UNIX Sitting above... computing Mike Azzara, associate publisher/editorial director, Open Systems Today http://docs.rinet.ru/UNIXy/unxfmau.htm (10 of 10) [4/27/1999 10:45:29 AM] UNIX Unleashed unxpt1au.htm q Part I — Finding Your Way Around UNIX Part I — Finding Your Way Around UNIX Operating Systems Getting Started: Basic Tutorial The UNIX File System: Go Climb a Tree Listing Files Popular Tools Popular File Tools Text Editing... USL, will be available from UCB UNIX and Standards Because of the multiple versions of UNIX and frequent cross-pollination between variants, many features have diverged in the different versions of UNIX With the increasing popularity of UNIX in the commercial and government sector came the desire to standardize the features of UNIX so that a user or developer using UNIX could depend on those features... Microsoft Windows SCO UNIX currently has a much larger base of available applications and is working to achieve binary compatibility with UnixWare Source Versions of "UNIX" Several versions of UNIX and UNIX- like systems have been made that are free or extremely cheap and include source code These versions have become particularly attractive to the modern-day hobbyist, who can now run a UNIX system at home... replacement for UNIX, and it aims for POSIX compliance There are current efforts to make Linux reliably run both SVR3.2 and SVR4 binaries There is also a project called WINE to create Microsoft Windows emulation capability for Linux Making Changes to UNIX http://docs.rinet.ru/UNIXy/unx01.htm (6 of 9) [4/27/1999 10:45:56 AM] UNIX Unleashed unx01.htm Many people considering making the transition to UNIX have... End Users 47 — UNIX Graphical User Interfaces for Programmers A — What's on the CD-ROM Disc http://docs.rinet.ru/UNIXy/unxfmau.htm (9 of 10) [4/27/1999 10:45:29 AM] UNIX Unleashed unxfmau.htm Foreword 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... recent releases of System V, Release 3 http://docs.rinet.ru/UNIXy/unx01.htm (4 of 9) [4/27/1999 10:45:56 AM] UNIX Unleashed unx01.htm (SVR3.2) and Release 4 (SVR4; the most recent version of SVR4 is SVR4.2) remain popular for computers ranging from PCs to mainframes All versions of UNIX based on the AT&T work require a license from the current owner, UNIX System Laboratories Berkeley Software Distributions . think of as UNIX, because together they constitute the UNIX interface. Figure 1.2. The layers of UNIX. UNIX Unleashed unx01.htm http://docs.rinet.ru/UNIXy/unx01.htm. Systems, and New Technologies UNIX Unleashed Table of Contents http://docs.rinet.ru/UNIXy/ (3 of 3) [4/27/1999 10:45:14 AM] UNIX UNLEASHED Copyright © 1994