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



TOC
FORWARD
HOME

UNIX Unleashed,
Internet Edition

Robin Burk and David B. Horvath, CCP, et al

Dedication

To Stephen P. Kowalchuk, who provided an IS manager and practicing network administrator's point of view.

----Robin Burk

This edition is dedicated to my parents and grandparents. Education and doing one's best was always important to them.

----David B. Horvath

Acknowledgments

Special thanks to Roger for support and grocery shopping. Also to the Laurelwood English Cockers, who intuitively understand how to negotiate a communications session (beg), allocate resources (if it's on the counter, it's ours!), and travel in encapsulated cells (show crates) over broadband highway networks.

----Robin Burk

As with all the other projects I get involved with, my wife and muse, Mary, has been tremendously supportive. Even when I spent my evenings and weekends at the keyboard. Of course, she filled her time by shopping (she said this, not me).

My parents, brothers, and the rest of family, who always wondered about the time I spent with computers, are now seeing the concrete results of it all.

I've been involved with this project for close to a year now. The development staff were very helpful and have certainly kept it interesting. I want to thank them and the other authors (especially those that I talked into helping out). This certainly turned out to be a bigger project (and resulting book) than any of us expected. I hope and expect that people will be looking at these two volumes as the definitive reference!

After I take a short rest, I will be looking for the next project. Although these things are really tiring, especially with the effort this one entailed, I miss them when I'm not working on one.

---- David B. Horvath

About the Authors

Robin Burk has over 25 years' experience in advanced software, computer, and data communications technologies. She has provided technical and managerial leadership for the development of language tools, communications software, operating systems, and multimedia applications. A successful executive in entrepreneurial companies, she consults on software product development and the use of the Internet for business success. Robin's undergraduate degree is in physics and math. She also holds an MBA in finance and operations. Robin's other passion is breeding, training, and showing dogs. She moderates an e-mail list for English Cocker Spaniel fanciers and can be reached at robink@wizard.net.

David B. Horvath, CCP, is a Senior Consultant with CGI Systems, Inc., an IBM Company, in the Philadelphia, Pennsylvania area. He has been a consultant for over twelve years and is also a part-time Adjunct Professor at local colleges teaching topics that include C Programming, UNIX, and Database Techniques. He is currently pursuing an M.S. degree in Dynamics of Organization at the University of Pennsylvania. He has provided seminars and workshops to professional societies and corporations on an international basis. David is the author of "UNIX for the Mainframer" and numerous magazine articles.

When not at the keyboard, he can be found working in the garden or soaking in the hot tub. He has been married for over ten years and has several dogs and cats.

David can be reached at unx2@cobs.com for questions related to this book. No Spam please!

Chris Byers is a systems administrator for a financial securities firm in Philadelphia. As a former consultant and disaster recovery specialist, he has many years of experience in the UNIX world with its many different variants. He lives in South Jersey with his wife, his son, and his cat. He can be reached at southst@voicenet.com.

With over two decades of full-time experience in information technology, Cameron Laird now manages his own consultancy, Network Engineered Solutions, just outside Houston. He has consistently found challenges during his career in bridging system heterogeneities with high reliability, high precision, or high performance knowledge bases. Most recently, that has meant engineering applications that combine components written in a range of languages to solve needs in process control. His bias that the most important communications requirements are those between humans has persistently led him back to sidelines in writing. Hypertext <URL: http://starbase.neosoft.com/~claird/> is his favorite medium.

Jeffrey A. Simon was graduated in 1970 from University of Minnesota Summa cum Laude in Mathematics. He continued with graduate work in computer science at the University of Minnesota, later obtaining his MBA from Pepperdine University.

For twenty-two years Mr. Simon has been professionally active in information systems management and development. Over the last decade he has consulted for clients including IBM, American Express, and CIGNA. He has conducted advanced information technology training in the international environment, including seminars attended by representatives of the U. S. Government, the U. S. Military, the Canadian Government, the British Government, NATO, Boeing, Du Pont, Exxon, General Electric, Grand Metropolitan, Hewlett-Packard, IBM, Monsanto, Siemens, Westinghouse, and numerous other major corporations. His recent interests include the application of artificial intelligence to analysis of the stock market.

David Till is a technical writer working in Toronto, Ontario, Canada. He holds a master's degree in computer science from the University of Waterloo; programming languages was his major field of study. He also has worked in compiler development and on version-control software. He lists his hobbies as "writing, comedy, walking, duplicate bridge, and fanatical support of the Toronto Blue Jays."

Sean Drew is a distributed object software developer, working primarily with UNIX, C++, and CORBA. Sean is married to his college sweetheart Sheri and together they have two children, Dylan Thomas and Terran Caitlin. At the time of this writing a third child is on the way, and depending on the gender will probably be named Erin Nichole, Brenna Nichole, or Ryan Patrick. When Sean is not busy with his family or church, he likes to brew beer. Anybody up for a nice imperial stout? Sean can be reached at ninkasi@worldnet.att.net.

Matt Curtin is Chief Scientist at Megasoft Online, keeping busy in the research and development of computer and network security, network computing, and platform-independent application development. He is an active member of communities related to firewalls, cryptography, and open operating systems. Previous to joining Megasoft Online, he worked at AT&T Bell Laboratories in the design, implementation, and management of firewalls, secure web servers, and Internet-based applications.

James Edwards (jamedwards@deloitte.ca) is an IT professional experienced in data communications, network integration, and systems design in both North America and Europe. He holds an M.S. in information technology from the University of London and a B.A. (Hons) from Middlesex University, both in the United Kingdom. James currently resides in Toronto, Canada, where he is employed as a manager with the Deloitte & Touche Consulting Group. His spare time is taken up with his girls, Denise, Lauren, and Poppy.

Michael R. Starkenburg is the Manager of Development and Operations for Digital City Inc., where he leads a team of engineers creating online content delivery systems and tools. Previously, he was responsible for the creation of the Internet's largest web site, www.aol.com, and several other high profile web sites. He holds degrees in business from The George Washington University and Saddleback College. Mike can be reached at http://www.starkenburg.com or mail to stark@aol.net.

Eric Goebelbecker has been working with market data and trading room systems in the New York City area for the past six years. He is currently the Director for Systems Development with MXNet Inc, a subsidiary of the Sherwood Group in Jersey City, New Jersey, where he is responsible for developing new market data and transaction distribution systems.

Bill Ball, a retired U.S. Coast Guard photojournalist, has been playing with and writing about computers since 1984.

Fred Trimble holds a master's degree in computer science from Villanova University. In his nine years with Unisys Corporation, he held many positions, including UNIX system administrator, C programmer, and Oracle database administrator. Currently, he is a senior consultant and instructor with Actium Corporation in Conshohocken, Pennsylvania, specializing in C++, Java, and the Brio data warehousing product line. He is currently pursuing a master's degree in software engineering from Drexel University.

Jim Scarborough was an intern at Silicon Graphics for four years where he worked with system administration, sales support, and technical support. He presently works at a startup company in Huntsville, Alabama. For recreation, Jim enjoys amateur radio (call sign KE4ROH) and ballroom dancing.

James C. Armstrong, Jr. is a software engineer with more than ten years of industry experience with UNIX and C.

Tell Us What You Think!

As a reader, you are the most important critic and commentator of our books. We value your opinion and want to know what we're doing right, what we could do better, what areas you'd like to see us publish in, and any other words of wisdom you're willing to pass our way. You can help us make strong books that meet your needs and give you the computer guidance you require.

Do you have access to the World Wide Web? Then check out our site at http://www.mcp.com.


NOTE: If you have a technical question about this book, call the technical support line at 317-581-3833 or send e-mail to support@mcp.com.

As the team leader of the group that created this book, I welcome your comments. You can fax, e-mail, or write me directly to let me know what you did or didn't like about this book--as well as what we can do to make our books stronger. Here's the information:

Fax: 317-581-4669
E-mail: opsys_mgr@sams.mcp.com
Mail: Dean Miller
Comments Department
Sams Publishing
201 W. 103rd Street
Indianapolis, IN 46290

Introduction

by Robin Burk and David B. Horvath, CCP

Welcome to the Second Edition of UNIX Unleashed.

Who Should Read This Book

Our highly popular first edition brought comprehensive, up-to-date information on UNIX to a wide audience. That original edition was already 1,600 pages. The new topics covered in this edition have obliged us to split the second edition into two volumes, namely, the System Administrator's Edition and the Internet Edition, which we'll refer to jointly as "the new" or the second edition. Though each volume can stand alone and may be read independently of the other, they form a complementary set with frequent cross-references. This new edition is written for:

  • People new to UNIX

  • Anyone using UNIX who wants to learn more about the system and its utilities

  • Programmers looking for a tutorial and reference guide to C, C++, Perl, awk, and the UNIX shells

  • System administrators concerned about security and performance on their machines

  • Webmasters and Internet server administrators

  • Programmers who want to write Web pages and implement gateways to server databases

  • Anyone who wants to bring his or her UNIX skills and knowledge base up-to-date

A lot has happened in the UNIX world since the first edition of UNIX Unleashed was released in 1994. Perhaps the most important change is the tremendous growth of the Internet and the World Wide Web. Much of the public Internet depends on UNIX-based servers. In addition, many corporations of all sizes have turned to UNIX as the environment for network and data servers. As UNIX fans have long known, the original open operating system is ideal for connecting heterogeneous computers and networks into a seamless whole.

What's New in UNIX Unleashed, Second Edition

This edition of UNIX Unleashed includes a substantial amount of new information describing Internet and World Wide Web technologies in UNIX. New topics include:

  • Programming Web pages with HTML

  • Object-oriented programming in C++

  • Programming Common Gateway Interfaces (CGI) using Perl, C/C++, HTML, and the UNIX shells

  • MIME, the Multipurpose Internet Mail Extension

  • HTTP, the HyperText Transfer Protocol

  • Web servers and server performance

As UNIX becomes the platform of choice for critical network and data applications, UNIX vendors have placed increased emphasis on system maturity, ease-of-use, and security capabilities. Even with the growth of Microsoft Windows NT, UNIX still has a place in the industry. It is more mature, more stable, more scaleable, and has a wider array of applications than NT. Many people claim that NT is the open operating system of the future; that may be true (I have my own personal opinion), but for now, UNIX holds that place.

We've also updated this edition of UNIX Unleashed to bring you current information regarding:

  • Frequently Asked Questions (FAQs) about the most popular variants of UNIX

  • Security issues and the technologies you can use to protect your system and its information against intruders and malicious users

  • The most popular Graphical User Interfaces (GUIs)

As with the original edition, we set out to bring users the most comprehensive, useful, and up-to-date UNIX guide. To meet this goal, we've added nearly two dozen new chapters and have revised much of the original material in the book. The resulting book is so large that it is now divided into two volumes. The System Administrator's Edition introduces UNIX and contains much of the information required for basic users and for systems administrators. The Internet Edition includes advanced information for programmers, Internet/Web developers, and those who need detailed information regarding specific UNIX flavors.

Coverage of Popular UNIX Variants

Based on input from some of the experts, application developers, consultants, and system administrators working in industry, we have provided information about a number of the UNIX variants. We split the variants into two categories: major and minor. This is not a comment on the quality or capabilities of the variant, but on the penetration in the marketplace (popularity).

We consider AIX, HP-UX, Solaris, and SVR4 to be major and BSD, IRIX, Linux, and SunOS to be minor players in the marketplace. There are other variants; the next edition may cover them as they become more popular.

You can identify where something specific to a variant is discussed by the icon next to it:

  • AIX[em]major[em]IBM's version that runs on the RS/6000 series of RISC systems and mainframes. Over 500,000 RS/6000 systems have been sold!

  • BSD[em]minor[em]This version has a lesser presence in the marketplace. Although many variants can trace their heritage to BSD, it is not that popular as a product.

  • HP-UX[em]major[em]Hewlett Packard's (HP) version with a strong hardware presence in the marketplace and a strong future growth path.

  • IRIX[em]minor[em]While the Silicon Graphics (SGI) machines are wonderful for graphics, they have not found wide acceptance in business environments.

  • Linux[em]minor[em]Although this is a very nice and free variant, it has little commercial presence in the marketplace (probably because corporations do not want to run their mission-critical applications without a vendor they can sue when there is a problem). See the SAMS Linux Unleashed series books (Red Hat and Slackware) for detailed information.

  • Solaris[em]major[em]Sun Microsystems' version with a strong hardware presence in the marketplace and a strong future growth path.

  • SunOs[em]minor[em]Largely being superseded by Solaris installations. A good variant, but it is difficult for a company to support two versions of UNIX at a time.

  • SVR4[em]major[em]This version has a strong presence in the marketplace. In addition, many variants can trace their heritage to System V Release 4.

CD-ROM Contents

We've also enhanced our CD-ROM with a C compiler, the most popular Web server software, and megabytes of other useful tools and information. The CD-ROM packaged with each volume contains exactly the same software and materials. Here are some of the noteworthy inclusions:

  • The entire text of both volumes in HTML format
  • Listings and code examples from various chapters in the volume
  • FreeBSD 2.2.5, full binary release
  • Linux Red Hat 4.2, full binary release [x86 platform only]
  • BASH, sources and documentation.
  • sendmail version 8.7
  • RFCs 821, 822, 1425, 1123, 976, 977, 1036
  • latest version of INN source code
  • GNU findutils 4.1
  • GNU fileutils 3.16
  • xv-3.10a
  • disktool (v2.0)
  • tcl/tk
  • screen
  • xarchie
  • xrn
  • SATAN
  • Crack (or equivalent)
  • Perl 5.x
  • LaTeX
  • Lynx
  • elm and pine
  • pico
  • UNIX sort utility
  • GNU awk, gawk
  • APACHE web server
  • GNU C compiler
  • emacs editor
  • gtar
  • gzip
  • gcc
  • gmake
  • NCSA Web Server
  • asWedit
  • missinglink
  • Weblint
  • Isearch and Isearch-cgi
  • @cgi.pm
  • LessTif 0.80 sources, Linux and FreeBSD bins
  • fvwm window manager
  • Enlightenment window manager
  • libg 2.7.2 (useful companion to C compiler)
  • acroread, Adobe Acrobat PDF reader (for Linux and FreeBSD)

More information about the CD-ROM contents is available on the final page, "What's on the CD-ROM."

To make use of the CD-ROM easier, whenever a reference in print is made to the CD-ROM, you will see an icon. You can also scan through the text to find the CD-ROM icons to find more information the disk contents.

Enjoy!

How These Volumes are Organized

The books are divided into parts; detailed information about each volume is in the next sections. Each volume also contains a glossary of terms and an index.

Whenever there is special information you should pay attention to, it will be placed in a blocks to grab your attention. There are three types of special blocks: note, tip, and caution.


NOTE: A note is used to provide you with information that you may want to pay attention to but is not critical. It provides you with information that can be critical but should not cause very much trouble.


TIP: A tip is used to make your life easier. It provides you with information so you do not have to go digging for information to solve a problem. These are based on real-life exposure to problems (and how they were solved).


CAUTION: A caution is used to grab your attention to prevent you from doing something that would cause problems. Pay close attention to cautions!

The icons shown in the CD-ROM Contents and Coverage of Popular UNIX Variants sections also provide a quick means of referencing information.

How the System Administrator's Edition Is Organized

The first volume, UNIX Unleashed, Systems Administrator Edition, consists of three major sections or parts. The general focus is getting you started using UNIX, working with the shells, and then administering the system.

Part I, Introduction to UNIX, is designed to get you started using UNIX. It provides you with the general information on the organization of the UNIX operating system, how and where to find files, and the commands a general user would want to use. Information is also provided on how to get around the network and communicating with other users on the system.

Part II, UNIX Shells, provides you the information on how to choose which shell to use and how to use that shell. The most popular shells: Bourne, Bourne Again (BASH), Korn, and C, are covered as well as a comparison between them. Under UNIX, the shell is what provides the user interface to the operating system.

Part III, System Administration, gets you started and keeps you going with the tasks required to administer a UNIX system. From installation through performance and tuning, the important topics are covered. The general duties of the system administrator are described (so you can build a job description to give to your boss). In case you are working on a brand-new UNIX system, the basics of UNIX installation are covered. Other topics covered in this section include: starting and stopping UNIX, user administration, file system and disk administration, configuring the kernel (core of the operating system), networking UNIX systems, accounting for system usage, device (add-on hardware) administration, mail administration, news (known as netnews or UseNet) administration, UUCP (UNIX to UNIX Copy Program, an early networking method still in wide use today) administration, FTP (File Transfer Protocol) administration, and finally, backing up and restoring files.

How the Internet Edition Is Organized

The second volume, UNIX Unleashed, Internet Edition, consists of seven major parts. The general focus is programming (GUI, application languages, and the Internet), text formatting (which involves embedding commands in your text and then processing it), security considerations (advanced system administration), developing for the Internet, "programming," getting you started using UNIX, working with the shells, and source code control and configuration management, and Frequently Asked Questions (FAQ) for the different variants of UNIX.

Part I, Graphical User Interfaces, provides you with information about using and writing GUI applications. When the operating system is UNIX, the GUI is the X-windowing system.

Part II, Programming, introduces the most popular program development tools in the UNIX environment. The most important part is how to enter your program (editing with vi and emacs)! The awk, Perl, C, and C++ programming languages are covered. Awk and Perl are interpreted languages designed for quick program development. C is the compiled language developed by Kernighan and Ritchie[em]UNIX is written in this language. C++ is an enhancement to the C language that supports object oriented programming. The final chapter in this section discusses the make utility, which provides a rule-based method to control program compilation.

Part III, Text Formatting and Printing, covers the tools that support the development, formatting, and printing of documents in the UNIX environment. These tools were much of the original justification for hardware that was used to develop UNIX. The formatting programs, nroff and troff, the standard macro packages, and many of the other document preparation tools are covered. In addition, developing your own text formatting macros is discussed.

Part IV, Security, is an advanced area of systems administration. One of the criticisms of UNIX is that it is not secure. It was developed in an environment where the individuals were trusted and sharing information was important. UNIX is capable of being very secure; you just have to know how to set it up. This section provides that information. The risks, available tools, and helpful organizations are covered.

Part V, UNIX and the Internet, introduces the tools used with the world wide web and the transmission of binary files via email (MIME). The web page definition language, HTML, is introduced, along with the methods of developing CGI (Common Gateway Interface[em]programs that run on the web server processing data from web pages) programs in shell scripting languages, Perl, and C/C++. Administrative information is provided in chapters on HTTP (HyperText Transport Protocol) and monitoring server activity.

Part VI, Source Control, covers the tools that UNIX provides to maintain control of your source code as different versions (and revisions) are created. The three major tools are RCS, CVS, and SCCS.

Part VII, Frequently Asked Questions, provides answers, as the name implies, to the most frequently asked questions about the various variants of UNIX. AIX, BSD, HP-UX, Linux, Solaris, SVR4, and IRIX are covered in individual chapters.

Conventions Used in This Volume

This book uses the following typographical conventions:

  • Menu names are separated from the individual menu options with a vertical bar (|). For example, "File|Save" means "Select the File menu and then choose the Save option."

  • New terms appear in italic.

  • All code appears in monospace. This includes pseudocode that is used to show a general format rather than a specific example.

  • Words that you are instructed to type appear in monospace bold.

  • Placeholders (words that stand for what you actually type) appear in italic monospace.

  • Lines of code that are too long to fit on only one line of this book are broken at a convenient place and continued on the next line. A code continuation character () precedes the new line. Any code that contains this character should be entered as one long line without a line break.

  • An ellipsis (...) in code indicates that some code has been omitted for the sake of brevity.

TOCFORWARDHOME


©Copyright, Macmillan Computer Publishing. All rights reserved.