i 201 West 103rd Street Indianapolis, IN 46290 David Pitts, et al. Red Hat LinuxSecond Edition Red Hat Linux, Second Edition UNLEASHED ii Publisher Dean Miller Executive Editor Jeff Koch Managing Editor Sarah Kearns Senior Indexer Ginny Bess Director of Software and User Services Cheryl Willoughby Brand Director Alan Bower This book is dedicated to TM3 and Associates. Thanks, guys (non-gender)!! —David Pitts Copyright © 1998 by Sams Publishing SECOND 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- 31173-9 Library of Congress Catalog Card Number: 97-68008 01 00 99 98 4 3 2 1 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 98-1 shows that the first printing of the book occurred in 1998. Composed in AGaramond and MCPdigital by Macmillan Computer Publishing 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. Red Hat Linux is a trademark of Red Hat Software. Acquisitions Editor Cari Skaggs Development Editors Mark Cierzniak Richard Alvey Software Development Specialist Jack Belbot Project Editor Dana Rhodes Lesh Copy Editors Carolyn Linn, Kate Talbot, Michael Brumitt, Chuck Hutchinson, Nancy Albright Indexer Cheryl Jackson Technical Reviewers Bill Ball, Sriranga R. Veeraraghavan, Robin Burk Editorial Coordinators Mandie Rowell Katie Wise Technical Edit Coordinator Lynette Quinn Resource Coordinators Charlotte Clapp Deborah Frisby Editorial Assistants Carol Ackerman, Andi Richter, Rhonda Tinch-Mize, Karen Williams Cover Designer Jason Grisham Cover Production Aren Howell Book Designer Gary Adair Copy Writer David Reichwein Production Team Supervisor Beth Lewis Production Bryan Flores, Julie Geeting, Kay Hoskin, Christy M. Lemasters, Darlena Murray, Julie Searls, Sossity Smith Overview iii Introduction xxiii Part I Introduction and Installation of Linux 1 Introduction to Red Hat Linux and UNIX 3 2 Installation of Your Red Hat System 11 3 LILO 27 Part II Configuring Other Servers 4 System Startup and Shutdown 37 5 Configuring and Building Kernels 53 6 Common Desktop Environment 75 7 SMTP and POP 97 8 FTP 131 9 Apache Server 153 10 X Window 175 Part III Hardware Connectivity and Devices 11 Filesystems, Disks, and Other Devices 195 12 Printing with Linux 229 13 TCP/IP Network Management 243 Part IV System Administration and Management 14 Getting Started with Red Hat Linux 299 15 Essential System Administration 319 16 Advanced System Administration 341 17 GNU Project Utilities 351 18 Backup and Restore 373 Part V Dealing with Others 19 User Accounts and Logins 383 20 System Security 395 21 Shell Programming 411 Red Hat Linux, Second Edition UNLEASHED iv Part VI Automation, Programming, and Modifying Source Code 22 Automating Tasks 437 23 C and C++ Programming 455 24 Perl Programming 487 25 tcl and tk Programming 499 26 Motif Programming 529 27 gawk Programming 545 28 Network Programming 583 Part VII Appendixes A The Linux Documentation Project 607 B Top 50 Linux Commands and Utilities 611 C The Linux Documentation Project Copyright License 629 D Glossary 633 E What’s on the CD-ROM 653 Index 655 v Contents Introduction xxiii Part I Introduction and Installation of Linux 1 Introduction to Red Hat Linux and UNIX 3 Advantages of Linux . 5 Copyright and Warranty 7 Where to Get Red Hat Linux . 7 System Requirements . 7 System Requirements— Intel . 8 System Requirements— SPARC . 8 System Requirements— Alpha . 8 Summary . . 9 2 Installation of Your Red Hat System Be Prepared, Be Very Prepared! 12 Installing Red Hat Linux . . 13 Creating the Boot and Supplemental Disks . 13 Installing Without Using a Boot Floppy 14 Virtual Consoles . . 14 Dialog Boxes 14 Step-by-Step Installation 15 Booting . . 15 The Installation Program . 15 Selecting an Installation Method . 17 CD-ROM Installation . 17 The Red Hat Package Manager 25 RPM Usage . 25 Summary . . 26 3 LILO 27 Installing and Configuring LILO . 28 Configuring LILO . 29 Using LOADLIN.EXE to Boot Linux . 33 How to Uninstall LILO . 33 Summary . . 33 Part II Configuring Other Servers 4 System Startup and Shutdown 37 The Boot Process 38 The Initialization Process and Startup Scripts . 38 init and /etc/inittab . 39 /etc/inittab and System States . 40 Red Hat Linux, Second Edition UNLEASHED vi tksysv and Managing Your Services 43 Shutting Down the Linux System 44 shutdown . 44 halt and reboot 45 When the System Crashes 46 Running as Root 47 Creating a Boot Disk . 47 Your File Toolbox . 48 Red Hat to the Rescue! When the System Won’t Boot 49 For More Information . 50 Summary . . 51 5 Configuring and Building Kernels 53 An Introduction to the Linux Kernel 54 Acquiring the Source Tree . 55 Patching the Source Tree . 57 Modules 57 Configuring the Linux Kernel 58 Starting the Configuration . 58 Stepping Through the Menus 59 Final Notes About Configuration 70 Building the Kernel . . 70 Installing the Kernel . 72 Recovering from Faulty Kernels . 73 Summary . . 73 6 Common Desktop Environment 75 Installation . 76 Getting Started with the CDE 77 Logging in to the CDE 77 The Desktop Environment . . 78 Customizing Your Session . . 81 The Style Manager . 81 The Front Panel 82 [...]... 323 Getting Help 328 Man Pages 329 Email 331 Red Hat Mailing Lists and Newsgroups 332 Other Newsgroups 334 Problem Solving— Logs 335 login.access 336 Other Files That Deny or Allow Users or Hosts 337 syslog 337 Wine—Accessing Windows Applications Under Linux 338 New Releases of Wine 339 Where to Get Copies of Wine ... 358 locate 358 find 359 xargs 361 Shell Utilities 363 Who’s Who in GNU 363 The id Commands 364 Contents Red Hat Linux, Second Edition UNLEASHED xii Checking What System You’re Running 365 Environment Variables and Shell Functions 365 Text Utilities 366 The head and tail Commands 366 The split Command ... 224 Testing CD Images 224 Other Character Devices 224 Summary 228 12 Printing with Linux 229 Printer Devices 230 How Do I Print? 231 The RHS Linux Print System Manager 232 Remote and LAN Printers 232 Local Printers 233 Linux Printing Commands 234 Simple Formatting 235 Other Helpful Printer Programs and Filters ... 244 A TCP/IP Primer 244 Subnetworking 246 Determining the Broadcast Address 247 The Next Generation of IP, IPv6 247 Getting a New IP Address 248 Contents Red Hat Linux, Second Edition UNLEASHED x The Network Card Solution 249 Stock Network Configuration 250 Using ifconfig 254 Using route 256 The Domain Name Service 258... 282 Connecting to the Net with PPP 288 Simple Client 289 On-Demand Dialing 293 Summary 294 Part IV System Administration and Management 14 Getting Started with Red Hat Linux 299 Organization 300 /bin and /sbin 300 /etc 301 /home 303 /mnt 303 /tmp and /var 303 /usr 304 RPM 305... Configuring an inetd Server 159 Configuring inetd 160 Running the Web Server for the First Time 162 Starting a Standalone Server 163 Starting an inetd Server 163 Contents Red Hat Linux, Second Edition UNLEASHED viii Starting and Stopping the Server 163 The start Script 164 The stop Script 164 The restart Script 164 Configuration File Listings... Manager 188 Compiling Programs That Use X 188 Some Common Problems 189 Compiling Sources for XFree86 190 Summary 191 Part III Hardware Connectivity and Devices 11 Filesystems, Disks, and Other Devices 195 Block Devices 197 Filesystems 197 The mount Command 198 Setting Up Filesystems 202 The Red Hat File System Manager 202... 430 The case Statement 431 Miscellaneous Statements 433 The break Statement 433 The exit Statement 433 Functions 434 Summary 434 Contents Red Hat Linux, Second Edition UNLEASHED xiv Part VI Automation, Programming, and Modifying Source Code 22 Automating Tasks 437 First Example—Automating Data Entry 438 Problem and Solution 438... 237 Some Program Tips 237 emacs 237 Applixware for Linux 238 Other Helpful Programs 239 xv 239 pbm Utilities 240 Ghostview 240 For More Information 240 Summary 241 13 TCP/IP Network Management 243 An Introduction to Networking 244 What Is an IP Number? 244 A TCP/IP Primer 244 Subnetworking... Backup 374 Selecting a Backup Medium 375 Selecting a Backup Tool 375 Backup Strategy 376 Performing Backups with tar and cpio 377 Restoring Files 378 What Is on the Tape? 378 Summary 379 Part V Dealing with Others 19 User Accounts and Logins 383 Adding Users 384 Editing etc/passwd 384 Editing /etc/group . Installation of Your Red Hat System Be Prepared, Be Very Prepared! 12 Installing Red Hat Linux Part I Introduction and Installation of Linux 1 Introduction to Red Hat Linux and UNIX 3 2 Installation of Your Red Hat System 11 3 LILO 27 Part II Configuring