Beginning Red Hat Linux 9

  

  

Table of Contents

Beginning Red Hat Linux 9...............................................................................................................................1

Introduction.........................................................................................................................................................4

  Who Is This Book For?...........................................................................................................................4 What You Need to Use This Book.........................................................................................................4 What Is Linux?........................................................................................................................................5

  Linus Torvalds and the Birth of Linux.............................................................................................5 Why Choose Linux?.........................................................................................................................6 What Is Red Hat Linux 9?................................................................................................................7

  What Is Covered in This Book?..............................................................................................................8 Conventions in This Book......................................................................................................................9 Customer Support.................................................................................................................................10

  Source Code and Updates...............................................................................................................10 Errata..............................................................................................................................................11 Technical Support...........................................................................................................................11 p2p.wrox.com.................................................................................................................................11

  

Chapter 1: Installing Red Hat Linux 9..........................................................................................................13

Overview...............................................................................................................................................13 Preparing for the Installation................................................................................................................14 The Software..................................................................................................................................14 The Hardware.................................................................................................................................14 Network Details..............................................................................................................................16 Getting Help...................................................................................................................................17 The Installation.....................................................................................................................................17 Booting off the CD.........................................................................................................................17 Testing the Media...........................................................................................................................18 The Graphical Installation Launch.................................................................................................20 Selecting the Default Language.....................................................................................................21 Selecting the Keyboard..................................................................................................................21 Selecting the Mouse.......................................................................................................................22 Selecting an Installation Type........................................................................................................22 Setting up the Disk Partitions.........................................................................................................23 Setting the Boot Loader..................................................................................................................25 Setting the Network Parameters.....................................................................................................26 Setting up the Firewall...................................................................................................................28 Setting Additional Language Support............................................................................................29 Setting the Time Zone....................................................................................................................30 Root Account Configuration..........................................................................................................30 Selecting Packages for Installation.................................................................................................31 The Automatic Installation Process................................................................................................32 Creating a Boot Disk......................................................................................................................33 Setting up the GUI..........................................................................................................................34 Finishing.........................................................................................................................................36 Booting Up.....................................................................................................................................36 First Boot........................................................................................................................................36 Logging In......................................................................................................................................39 Summary...............................................................................................................................................40

  

Table of Contents

  

Chapter 2: Red Hat Linux 9 Basics................................................................................................................41

Overview...............................................................................................................................................41 Moving Around the Desktop................................................................................................................41 Using Applications.........................................................................................................................43 Shutting Down the Computer.........................................................................................................49 The File System....................................................................................................................................50 The File System Hierarchy.............................................................................................................50 Adding Devices to the Filesystem..................................................................................................54 Navigating in the File System........................................................................................................57 Managing the Hardware........................................................................................................................60 Finding the Existing Hardware.......................................................................................................61 Configuring the Desktop.......................................................................................................................71 Using the Desktop Control Center.................................................................................................71 Managing Processes..............................................................................................................................73 Managing Users....................................................................................................................................78 Summary...............................................................................................................................................80

Chapter 3: Connecting to the Internet...........................................................................................................82

Overview...............................................................................................................................................82 Connecting to the Internet.....................................................................................................................82 Network Configuration Tool..........................................................................................................83 Analog Modem Connections..........................................................................................................84 High−bandwidth Connections........................................................................................................86 Connecting to a LAN.....................................................................................................................88 Other Connection Types.................................................................................................................89 Managing Multiple ISPs and Connections...........................................................................................90 Software and Configuration..................................................................................................................94 Web Browsers................................................................................................................................94 E−mail and News Clients...............................................................................................................97 Other Software...............................................................................................................................99 Summary.............................................................................................................................................102

Chapter 4: Installing Software.....................................................................................................................103

Overview.............................................................................................................................................103 What Is RPM?.....................................................................................................................................103 The RPM Package Management (GUI) Tool...............................................................................104 The RPM Command Line Tool..........................................................................................................110 Querying Packages.......................................................................................................................110 RPM Package Security.................................................................................................................113 Installing Packages.......................................................................................................................115 Removing Packages.....................................................................................................................117 Upgrading Packages.....................................................................................................................118 Verifying Package Integrity.........................................................................................................119 Package Installation in TAR Format...................................................................................................119 Summary.............................................................................................................................................121

Chapter 5: Everyday Applications...............................................................................................................123

Overview.............................................................................................................................................123 Office Applications.............................................................................................................................123 Red Hat Linux and Office Applications.......................................................................................124

  

Table of Contents

   Chapter 5: Everyday Applications Installing Office Applications......................................................................................................125 Starting an OpenOffice Application.............................................................................................126 Common Functionality.................................................................................................................127 Conversion Quality and Considerations.......................................................................................133 Using OpenWriter for Word Processing......................................................................................133 Using OpenCalc for Spreadsheets................................................................................................134 Using OpenImpress for Presentations..........................................................................................135 Internet Applications...........................................................................................................................136 The Mozilla Web Browser...........................................................................................................136 The GAIM Instant Messenger Application..................................................................................138 Personal Information Management.....................................................................................................140 Installing Evolution......................................................................................................................140 Setting up Evolution.....................................................................................................................140 Using Evolution............................................................................................................................141 Importing E−mail from other Systems.........................................................................................146 Multimedia Applications....................................................................................................................147 Audio Applications.......................................................................................................................148 Graphics Applications..................................................................................................................154 System Applications...........................................................................................................................156 A Simple Text Editor...................................................................................................................156 A File Management Application..................................................................................................157 A File Compression and Archiving Application..........................................................................158 Emulators......................................................................................................................................159 Summary.............................................................................................................................................160

Chapter 6: The Shell......................................................................................................................................161

Overview.............................................................................................................................................161 The Shell as a Command Line Interface.............................................................................................161 Different Types of Shell...............................................................................................................162 Built−in Programs and External Programs.........................................................................................163 Some Common Shell Commands.......................................................................................................164 File System Commands................................................................................................................164 Process Management Commands.................................................................................................168 Administrative Commands...........................................................................................................170 Special Keys and Shortcuts.................................................................................................................172 Control Keystrokes.......................................................................................................................172 Cursor Keys..................................................................................................................................173 Auto−completion..........................................................................................................................175 Command Line Syntax.......................................................................................................................176 File Globbing................................................................................................................................176 Aliases..........................................................................................................................................178 Environment Variables.................................................................................................................179 I/O Redirection.............................................................................................................................180 Configuring the Shell..........................................................................................................................182 Managing Tasks..................................................................................................................................183 Processes......................................................................................................................................184 Job Control...................................................................................................................................184 Scheduling Tasks..........................................................................................................................185 Shell Scripting.....................................................................................................................................186

  

Table of Contents

   Chapter 6: The Shell Variables.......................................................................................................................................187 Literal Usage of Special Characters.............................................................................................187 Conditional Constructs.................................................................................................................188 Loops............................................................................................................................................190 Summary.............................................................................................................................................191

Chapter 7: The File System...........................................................................................................................192

Overview.............................................................................................................................................192 What Is the File System?....................................................................................................................192 The Anatomy of a File..................................................................................................................192 File Search Utilities............................................................................................................................204 Searching with the locate Command............................................................................................204 Searching with the find Command...............................................................................................206 Searching with the GNOME Search Tool....................................................................................208 Text Searches...............................................................................................................................208 Navigating the File System.................................................................................................................210 Managing Drives and Partitions..........................................................................................................215 Mounting Drives...........................................................................................................................216 Partitions.......................................................................................................................................218 Adding a New Hard Disk.............................................................................................................222 File System Maintenance....................................................................................................................224 Precautions...................................................................................................................................224 Running fsck.................................................................................................................................225 Tuning the File System.................................................................................................................225 Summary.............................................................................................................................................226

Chapter 8: Managing Your User Accounts.................................................................................................227

Overview.............................................................................................................................................227 The Purpose of Different User Accounts............................................................................................228 Superusers and Normal Users......................................................................................................228 The Red Hat User Manager................................................................................................................229 How Linux Stores User Account Information....................................................................................234 User Accounts and their Properties (the /etc/passwd File)...........................................................235 User Account Passwords (the /etc/shadow File)..........................................................................237 Groups (the /etc/group File).........................................................................................................239 Advanced User Account Management...............................................................................................240 Some Useful Command Line Tools.............................................................................................240 Adding Users at the Command Line............................................................................................241 Modifying One's Own User Account...........................................................................................244 Deleting User Accounts................................................................................................................248 Advanced Group Management...........................................................................................................248 Users, Groups, and File System Permissions.....................................................................................250 First Scenario: Private Files.........................................................................................................251 Second Scenario: Public Read−only Files...................................................................................251 Third Scenario: Restricted Read−Only........................................................................................252 Fourth Scenario: Restricted Write................................................................................................253 Fifth Scenario: Restricted Write, Public Read.............................................................................255 Sixth Scenario: Restricted Write, Restricted Read.......................................................................255 When root Is Not Necessary...............................................................................................................256

  

Table of Contents

   Chapter 8: Managing Your User Accounts Mounting Devices........................................................................................................................257 Using the su Command................................................................................................................259 Compiling, Installing, and Running Software..............................................................................261 Who Is Logged In?..............................................................................................................................262 Summary.............................................................................................................................................263

Chapter 9: Building Networks......................................................................................................................265

Overview.............................................................................................................................................265 Networking.........................................................................................................................................266 Red Hat Linux and Networking...................................................................................................266 Assumptions for Network Setup..................................................................................................267 Setting up a Web Server.....................................................................................................................270 The Apache Web Server...............................................................................................................271 Setting up an FTP Server....................................................................................................................277 FTP Servers in the Red Hat Linux Distribution...........................................................................278 Installing the vsftpd FTP Server...................................................................................................279 Using Your FTP Server................................................................................................................280 Setting up a Print Server.....................................................................................................................286 Print Servers on Redhat Linux 9..................................................................................................286 Setting up a File Server.......................................................................................................................291 An Overview of Samba................................................................................................................292 Samba Configuration with SWAT...............................................................................................295 Setting up a Mail Server.....................................................................................................................304 What Is a Mail Server?.................................................................................................................305 E−mail Application Types...........................................................................................................305 A Simple Example Using Sendmail.............................................................................................307 Setting up a DHCP Server..................................................................................................................312 How Does DHCP Work?.............................................................................................................312 The Benefits of DHCP.................................................................................................................313 Summary.............................................................................................................................................319

Chapter 10: Advanced System Administration..........................................................................................320

Overview.............................................................................................................................................320 System Configuration.........................................................................................................................320 Example: Finding the DNS Server...............................................................................................321 Configuration Files.......................................................................................................................321 Logging...............................................................................................................................................329 Viewing Logs...............................................................................................................................329 Searching Log Files......................................................................................................................331 Understanding the Logging Process.............................................................................................332 Backing Up and Archiving.................................................................................................................333 Backup Strategy...........................................................................................................................333 Applications and Tools for Archiving..........................................................................................335 Archiving with cpio......................................................................................................................337 Archiving with dump....................................................................................................................339 Building from Source..........................................................................................................................343 Installing Development Tools and Libraries................................................................................344 Building the Application..............................................................................................................344 Rebuilding the Linux Kernel..............................................................................................................348

  

Table of Contents

   Chapter 10: Advanced System Administration Why Rebuild the Kernel?.............................................................................................................348 Initializing the Kernel...................................................................................................................349 A Small, Lean Kernel...................................................................................................................350 Summary.............................................................................................................................................358

Chapter 11: Managing Your System with Perl...........................................................................................359

Overview.............................................................................................................................................359 What Is Perl?.......................................................................................................................................360 Advantages...................................................................................................................................361 Disadvantages...............................................................................................................................362 Installation..........................................................................................................................................362 Installing Extensions....................................................................................................................363 Learning Perl.......................................................................................................................................365 How to Start..................................................................................................................................365 Application 1: Who Can Get In?..................................................................................................366 Who Can Get In? Take II.............................................................................................................369 Application 2: Send a Quick E−Mail...........................................................................................370 Application 3: What Is My System Load?...................................................................................376 Application 4: Disk Usage Monitor.............................................................................................386 And Finally.........................................................................................................................................393 Summary.............................................................................................................................................394

Chapter 12: Security......................................................................................................................................395

What Is Meant by Computer Security?...............................................................................................395 Identifying What Is Valuable.......................................................................................................395 Potential Threats...........................................................................................................................396 Countering the Threats........................................................................................................................397 Hardware.............................................................................................................................................397 Physical Security of the Hardware...............................................................................................397 Hardware Failure..........................................................................................................................398 Local Security.....................................................................................................................................399

  (Mis)using the root Account.........................................................................................................399 Passwords.....................................................................................................................................399

  Keeping Software Up to Date.............................................................................................................405 Registering for Red Hat Network.................................................................................................405

  Monitoring Security............................................................................................................................406 System Logs.................................................................................................................................406 System Integrity...........................................................................................................................409

  Network Security................................................................................................................................414 Network Services.........................................................................................................................415 Firewalls.......................................................................................................................................425 Security Awareness......................................................................................................................431

  Where to find out more.......................................................................................................................432 Summary.............................................................................................................................................432

  

Chapter 13: Where to Now?.........................................................................................................................434

Overview.............................................................................................................................................434 Online Resources and Licensing Schemes.........................................................................................434 Software Resources......................................................................................................................434

  

Table of Contents

   Chapter 13: Where to Now? Documentation Resources............................................................................................................435 Open Source Licenses..................................................................................................................435 System Administration Applications..................................................................................................437 The SysAdmin Application..........................................................................................................437 The GNOME Workstation Command Center..............................................................................438 Webmin........................................................................................................................................438 RT: The Request Tracker.............................................................................................................440 Development Applications..................................................................................................................440

  jEdit..............................................................................................................................................440 Developing C/C++ Applications..................................................................................................441 Developing Python Applications..................................................................................................443 PHP: Hypertext Preprocessor.......................................................................................................444 MySQL Database Engine.............................................................................................................446

  Summary.............................................................................................................................................447

  

List of "Try it Outs" and "How it Works"..................................................................................................449

  Chapter 3: Connecting to the Internet.................................................................................................449 Chapter 4: Installing Software............................................................................................................449 Chapter 6: The Shell...........................................................................................................................449 Chapter 7: The File System................................................................................................................449 Chapter 8: Managing Your User Accounts.........................................................................................449 Chapter 9: Building Networks............................................................................................................450 Chapter 10: Advanced System Administration...................................................................................450 Chapter 12: Security...........................................................................................................................450

Beginning Red Hat Linux 9

  Sandip Bhattacharya, Pancrazio De Mauro, Shishir Gundavaram, Mark Mamone, Kalip Sharma, Deepak Thomas, Simon Whiting Published by Wiley Publishing, Inc.

  10475 Crosspoint Boulevard Indianapolis, IN 46256 www.wiley.com Copyright © 2003 by Wiley Publishing, Inc., Indianapolis, Indiana Published simultaneously in Canada Library of Congress Control Number: 2003107085

  ISBN: 0−7645−4378−4 Manufactured in the United States of America 10 9 8 7 6 5 4 3 2 1

  1B/RV/QX/QT/IN No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization through payment of the appropriate per−copy fee to the Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA 01923, (978) 750−8400, fax (978) 646−8700. Requests to the Publisher for permission should be addressed to the Legal Department, Wiley Publishing, Inc., 10475 Crosspoint Blvd., Indianapolis, IN 46256, (317) 572−3447, fax (317) 572−4447, E−Mail: <permcoordinator@wiley.com>.

  Limit of Liability/Disclaimer of Warranty: While the publisher and author have used their best efforts in preparing this book, they make no representations or warranties with respect to the accuracy or completeness of the contents of this book and specifically disclaim any implied warranties of merchantability or fitness for a particular purpose. No warranty may be created or extended by sales representatives or written sales materials.

  Beginning Red Hat Linux 9 The advice and strategies contained herein may not be suitable for your situation. You should consult with a professional where appropriate. Neither the publisher nor author shall be liable for any loss of profit or any other commercial damages, including but not limited to special, incidental, consequential, or other damages.

  For general information on our other products and services or to obtain technical support, please contact our Customer Care Department within the U.S. at (800) 762−2974, outside the U.S. at (317) 572−3993 or fax (317) 572−4002.

  Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be available in electronic books.

  

Trademarks: Wiley, the Wiley Publishing logo, Wrox, the Wrox logo, the Wrox Programmer to Programmer

  logo and related trade dress are trademarks or registered trademarks of John Wiley & Sons, Inc. and/or its affiliates in the United States and other countries, and may not be used without written permission. Linux is a trademark of Linus Torvalds. Red Hat is a trademark of Red Hat, Inc. All other trademarks are the property of their respective owners. Wiley Publishing, Inc., is not associated with any product or vendor mentioned in this book.

  About the Authors

Sandip Bhattacharya is an independent technology consultant specializing in Open Source technologies. He

  is a Red Hat Certified Engineer (RHCE) and besides holding degrees in engineering and management is the author of a number of books and articles on Open Source software. He currently runs Puroga Technologies, a small startup with a focus on helping businesses use the Open Source revolution to their advantage. He can be contacted at <sandip@puroga.com>. Sandip is an active participant in various Open Source communities in India, especially his local LUG, the Indian Linux Users Group, Delhi (ILUGD).

  

Pancrazio 'Ezio' de Mauro has been using Red Hat Linux since 1996. He is a Linux consultant specializing

  in system integration, mobile technologies, and training. He actively supports and advocates the use of free software. Ezio spends most of his free time traveling and backpacking. He welcomes comments and questions at his e−mail address, <pdm@demauro.net>.

  

Shishir Gundavaram is the Chief Technology Officer for MechanicNet Group, a company that specializes in

  providing CRM services for the automotive repair and maintenance industry. When he is not dealing with auto mechanics and broken−down cars, Shishir consults for a number of companies, designing architecture and providing technical expertise. He has more than a decade of experience in various aspects of software development and is considered a foremost expert in wireless applications, distributed systems, electronic commerce, and web backend architecture. He is also the author of various articles and books, including

  Professional Perl Development , CGI Programming on the World Wide Web, and Scripting Languages: Automating the Web