Red Hat Fedora Linux 2 All-in-One Desk Reference For Dummiesx Chapter 2: Installing Fedora Core.. .31 Following the Installation Steps ...31 Checking Your PC’s Hardware ...33 Setting Asi
Trang 5Red Hat Fedora Linux 2 All-in-One Desk Reference For Dummies
Published by
Wiley Publishing, Inc.
111 River Street
Hoboken, NJ 07030-5774
Copyright © 2004 by Wiley Publishing, Inc., Indianapolis, Indiana
Published by Wiley Publishing, Inc., Indianapolis, Indiana
Published simultaneously in Canada
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 ted 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-8600 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-4355, e-mail:
permit-brandreview@wiley.com.
Trademarks: Wiley, the Wiley Publishing logo, For Dummies, the Dummies Man logo, A Reference for the
Rest of Us!, The Dummies Way, Dummies Daily, The Fun and Easy Way, Dummies.com, 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 Red Hat and Fedora are trademarks or registered trademarks of Red Hat, Inc Linux is a registered trademark of Linus Torvalds 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.
LIMIT OF LIABILITY/DISCLAIMER OF WARRANTY: THE PUBLISHER AND THE AUTHOR MAKE NO REPRESENTATIONS
OR WARRANTIES WITH RESPECT TO THE ACCURACY OR COMPLETENESS OF THE CONTENTS OF THIS WORK AND SPECIFICALLY DISCLAIM ALL WARRANTIES, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE NO WARRANTY MAY BE CREATED OR EXTENDED BY SALES OR PROMOTIONAL MATERI- ALS THE ADVICE AND STRATEGIES CONTAINED HEREIN MAY NOT BE SUITABLE FOR EVERY SITUATION THIS WORK IS SOLD WITH THE UNDERSTANDING THAT THE PUBLISHER IS NOT ENGAGED IN RENDERING LEGAL, ACCOUNTING, OR OTHER PROFESSIONAL SERVICES IF PROFESSIONAL ASSISTANCE IS REQUIRED, THE SERVICES
OF A COMPETENT PROFESSIONAL PERSON SHOULD BE SOUGHT NEITHER THE PUBLISHER NOR THE AUTHOR SHALL BE LIABLE FOR DAMAGES ARISING HEREFROM THE FACT THAT AN ORGANIZATION OR WEBSITE IS REFERRED TO IN THIS WORK AS A CITATION AND/OR A POTENTIAL SOURCE OF FURTHER INFORMATION DOES NOT MEAN THAT THE AUTHOR OR THE PUBLISHER ENDORSES THE INFORMATION THE ORGANIZATION OR WEBSITE MAY PROVIDE OR RECOMMENDATIONS IT MAY MAKE FURTHER, READERS SHOULD BE AWARE THAT INTERNET WEBSITES LISTED IN THIS WORK MAY HAVE CHANGED OR DISAPPEARED BETWEEN WHEN THIS WORK WAS WRITTEN AND WHEN IT IS READ
For general information on our other products and services or to obtain technical support, please tact 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.
con-Wiley also publishes its books in a variety of electronic formats Some content that appears in print may not be available in electronic books.
Library of Congress Control Number is available from the publisher.
ISBN: 0-7645-6793-4
Manufactured in the United States of America
10 9 8 7 6 5 4 3 2 1
1O/SR/QX/QU/IN
Trang 6About the Author
Naba Barkakati is an electrical engineer and a successful computer-book
author who has experience in a wide variety of systems, ranging from MS-DOSand Windows to UNIX and Linux He bought his first personal computer — anIBM PC-AT — in 1984 after graduating with a PhD in electrical engineering fromthe University of Maryland at College Park While pursuing a full-time career inengineering, Naba dreamed of writing software for the emerging PC softwaremarket As luck would have it, instead of building a software empire likeMicrosoft, he ended up writing successful computer books Currently, Naba is
a Senior Level Technologist at the Center for Technology and Engineering inthe U.S General Accounting Office
Over the past 15 years, Naba has written over 25 computer books on a number
of topics ranging from Windows programming with C++ to Linux He has
authored several bestselling titles, such as The Waite Group’s Turbo C++ Bible,
Object-Oriented Programming in C++, X Window System Programming, Visual C++ Developer’s Guide, Borland C++ 4 Developer’s Guide, and Linux Secrets His
books have been translated into many languages, including Spanish, French,Polish, Greek, Italian, Chinese, Japanese, and Korean Naba’s most recent book
is Red Hat Linux 9 Professional Secrets, also published by Wiley.
Naba lives in North Potomac, Maryland, with his wife Leha, and their dren, Ivy, Emily, and Ashley
Trang 8I would like to thank Jason Luster for reviewing the manuscript for technicalaccuracy and providing many useful suggestions for improving the book’scontent.
Thanks to everyone at Wiley Publishing for transforming my raw manuscriptinto this well-edited and beautifully packaged book
Of course, there would be no reason for this book if it were not for Linux Forthis, we have Linus Torvalds and the legions of Linux developers around theworld to thank Thanks to Red Hat for providing beta copies of Red Hat Linuxand the publisher’s edition CDs that are bundled with this book
Finally, and as always, my greatest thanks go to my wife, Leha, and ourdaughters, Ivy, Emily, and Ashley — it is their love and support that keeps megoing Thanks for being there!
Trang 9Publisher’s Acknowledgments
We’re proud of this book; please send us your comments through our online registration form located at www.dummies.com/register/.
Some of the people who helped bring this book to market include the following:
Acquisitions, Editorial, and
Media Development
Project Editor: Linda Morris
Acquisitions Editor: Terri Varveris
Copy Editor: Rebecca Senninger
Technical Editor: Jason Luster
Editorial Manager: Leah Cameron
Permissions Editor: Laura Moss
Media Development Specialist: Travis Silvers
Media Development Manager:
Laura VanWinkle
Media Development Supervisor:
Richard Graves
Editorial Assistant: Amanda Foxworth
Cartoons: Rich Tennant, www.the5thwave.com
Proofreaders: Carl William Pierce,
Sossity Smith, Brian H Walls
Indexer: Lynnzee Elze
Publishing and Editorial for Technology Dummies
Richard Swadley, Vice President and Executive Group Publisher
Andy Cummings, Vice President and Publisher
Mary C Corder, Editorial Director
Publishing for Consumer Dummies
Diane Graves Steele, Vice President and Publisher
Joyce Pepple, Acquisitions Director
Composition Services
Gerry Fahey, Vice President of Production Services
Debbie Stailey, Director of Composition Services
Trang 10Contents at a Glance
Introduction 1
Book I: Fedora Basics 7
Chapter 1: Introducing Fedora Core .9
Chapter 2: Installing Fedora Core 31
Chapter 3: Troubleshooting and Configuring Fedora Core 57
Chapter 4: Trying Out Fedora Core 75
Chapter 5: Cool Fedora Core Install Projects 99
Book II: Workstations and Applications 109
Chapter 1: Exploring the GUI Desktops .111
Chapter 2: Learning the Shell 135
Chapter 3: Navigating the Linux File System .153
Chapter 4: Exploring Fedora Core Applications 169
Chapter 5: Using Text Editors .199
Book III: OpenOffice.org .211
Chapter 1: Writing with OpenOffice.org Writer .213
Chapter 2: Preparing Spreadsheets with OpenOffice.org Calc 237
Chapter 3: Making Presentations with OpenOffice.org Impress .249
Chapter 4: Drawing with OpenOffice.org Draw .261
Book IV: Networking 269
Chapter 1: Connecting to the Internet .271
Chapter 2: Setting Up a Local Area Network 295
Chapter 3: Adding a Wireless Ethernet LAN .307
Chapter 4: Managing the Network 319
Chapter 5: Cool Networking Projects 329
Book V: Internet .335
Chapter 1: Exchanging E-Mail and Instant Messages 337
Chapter 2: Using the Web .351
Chapter 3: Reading Newsgroups .371
Chapter 4: Transferring Files with FTP .383
Trang 11Book VI: Administration .391
Chapter 1: Performing Basic System Administration .393
Chapter 2: Managing Users .425
Chapter 3: Managing the File System 437
Chapter 4: Managing Applications .461
Chapter 5: Managing Devices and Printers .479
Chapter 6: Upgrading and Customizing the Kernel 493
Book VII: Security .519
Chapter 1: Understanding Network and Host Security .521
Chapter 2: Securing the Host .535
Chapter 3: Securing the Network .557
Chapter 4: Performing Security Audits 577
Book VIII: Internet Servers .595
Chapter 1: Managing the Servers .597
Chapter 2: Running the Apache Web Server 615
Chapter 3: Setting Up the FTP Server .639
Chapter 4: Serving Up Mail and News 647
Chapter 5: Setting Up DNS 675
Chapter 6: Running Samba and NFS 695
Book IX: Programming .707
Chapter 1: Fedora Core Programming Essentials 709
Chapter 2: Programming in C 735
Chapter 3: Writing Shell Scripts 767
Chapter 4: Programming in Perl .779
Appendix: About the DVD .807
Index 811
Trang 12Table of Contents
Introduction 1
About This Book 1
Conventions Used in This Book .2
What You Don’t Have to Read .2
Who Are You? .3
How This Book Is Organized 3
What’s on the DVD? .4
Icons Used in This Book 5
Where to Go from Here 5
Book I: Fedora Basics 7
Chapter 1: Introducing Fedora Core .9
What Is Fedora Core? 9
Operating systems and Linux .9
Linux distributions .11
Transitioning to the Fedora Project 11
Making sense of version numbers 12
Under the hood in Linux kernel 2.6 13
What Fedora Core Includes 16
GNU software .16
GUIs and applications .19
Networks 20
Internet servers .21
Software development .22
Online documentation .23
What Fedora Core Helps You Manage .25
Disks, CD-ROMs, and DVD-ROMs .25
Peripheral devices 26
File systems and sharing .27
Network 27
How Do I Get Started? 28
Install 28
Configure 28
Explore 29
Learn 29
Trang 13Red Hat Fedora Linux 2 All-in-One Desk Reference For Dummies
x
Chapter 2: Installing Fedora Core .31
Following the Installation Steps .31
Checking Your PC’s Hardware .33
Setting Aside Space for Fedora Core .34
Defragmenting your hard disk .34
Resizing your hard disk partition 36
Starting the Fedora Core Installation .39
Selecting Keyboard, Mouse, and Installation Type 40
Partitioning the Disk for Fedora Core 43
Setting Up Key System Parameters 47
Installing the boot loader .47
Configuring the network 48
Configuring the firewall and SELinux .50
Selecting languages to support .51
Setting the time zone .51
Setting the root password .52
Selecting and Installing the Package Groups 53
Chapter 3: Troubleshooting and Configuring Fedora Core .57
Using Text Mode Installation .58
Using the linux noprobe Command .58
Troubleshooting X .59
Resolving Other Installation Problems 61
The fatal signal 11 error 61
Using kernel boot commands .62
Setting Up Printers 64
Turning On Sound .68
Adding User Accounts .69
Managing DVDs and CD-ROMs .71
Installing RPM Packages 72
Chapter 4: Trying Out Fedora Core .75
Booting Fedora Core .75
Exploring GUI Desktops 81
GNOME 81
KDE 88
Playing with the Shell .94
Starting the Bash shell 95
Understanding shell commands 95
Trying a few Linux commands 96
Shutting Down .98
Chapter 5: Cool Fedora Core Install Projects .99
Joining the BitTorrent 99
Things you need .100
Steps to follow .100
Trang 14Table of Contents xi
Burning Fedora Core CDs 103
Things you need .103
Steps to follow .103
Preparing a Fedora Core DVD 104
Things you need .104
Steps to follow .105
Doing an FTP Install .107
Things you need .107
Steps to follow .107
Book II: Workstations and Applications .109
Chapter 1: Exploring the GUI Desktops .111
Learning the Common Features of the GUIs .111
Desktop pop-up menus 112
Icon pop-up menus 113
The panel 114
The Main Menu .116
Exploring GNOME .119
Using the Nautilus shell .120
Configuring GNOME .124
Exploring KDE 127
Using Konqueror 128
Configuring KDE .132
Chapter 2: Learning the Shell .135
Opening Terminal Windows and Virtual Consoles .135
Using the Bash Shell .136
Learning the syntax of shell commands 136
Combining shell commands 138
Controlling command input and output 138
Typing less with automatic command completion 140
Going wild with asterisks and question marks 140
Repeating previously typed commands .142
Learning Linux Commands .142
Becoming root (superuser) 146
Managing processes 147
Working with date and time .147
Processing files .148
Writing Shell Scripts .151
Chapter 3: Navigating the Linux File System 153
Understanding the Linux File System .153
Navigating the File System with Linux Commands 157
Commands for directory navigation 158
Commands for directory listings and permissions 159
Trang 15Red Hat Fedora Linux 2 All-in-One Desk Reference For Dummies
xii
Commands for changing permissions and ownerships .162
Commands for working with files 163
Commands for working with directories 164
Commands for finding files .165
Commands for mounting and unmounting .166
Commands for checking disk-space usage .167
Chapter 4: Exploring Fedora Core Applications .169
Taking Stock of the Fedora Core Applications .169
Office Applications and Tools .171
Calculators 172
Commercially available office applications for Linux 173
aspell spelling checker .175
Databases 176
Adding a database user .177
Reviewing the steps to build the database .178
Designing the database 179
Creating an empty database .180
Using the PostgreSQL interactive terminal .180
Defining a table .181
Inserting records into a table 182
Querying the database .182
Multimedia Applications .183
Using a digital camera 183
Playing audio CDs 186
Playing sound files .187
Burning a CD .188
Graphics and Imaging .193
The GIMP .194
Gnome Ghostview .196
Chapter 5: Using Text Editors .199
Using GUI Text Editors 199
Text Editing with ed and vi .200
Using ed .201
Using vi .204
Book III: OpenOffice.org .211
Chapter 1: Writing with OpenOffice.org Writer .213
Getting Documents from Others .214
Taking Stock of OpenOffice.org Writer .215
Trang 16Table of Contents xiii
Getting Started with Writer 216
Examining the Writer main window .217
Setting up Writer 218
Preparing Documents in Writer 221
Editing and reviewing documents .221
Using styles and templates .224
Performing page layout .228
Creating and inserting graphics .231
Using fields .233
Working with large documents .235
Chapter 2: Preparing Spreadsheets with OpenOffice.org Calc .237
Taking Stock of OpenOffice.org Calc 237
Getting Started with Calc .238
Examining the Calc main window .239
Setting up Calc .240
Using Calc 241
Entering and formatting data 241
Calculating and charting data 244
Chapter 3: Making Presentations with OpenOffice.org Impress 249
Taking Stock of OpenOffice.org Impress .249
Getting Started with Impress 250
Using Impress .253
Preparing presentations .254
Adding graphics and special effects .257
Delivering presentations .260
Chapter 4: Drawing with OpenOffice.org Draw .261
Taking Stock of OpenOffice.org Draw .261
Getting Started with Draw 262
Using Draw .264
Book IV: Networking .269
Chapter 1: Connecting to the Internet .271
Understanding the Internet .271
Deciding How to Connect to the Internet .272
Connecting with DSL 274
How DSL works .274
DSL alphabet soup: ADSL, IDSL, SDSL .275
Typical DSL setup 276
Trang 17Red Hat Fedora Linux 2 All-in-One Desk Reference For Dummies
xiv
Connecting with a Cable Modem .279
How cable modem works .280
Typical cable modem setup .282
Setting Up Dial-Up Networking .284
Connecting the modem .286
Testing the modem 289
Setting up and activating a PPP connection .291
Configuring CHAP and PAP authentication .293
Chapter 2: Setting Up a Local Area Network .295
Understanding TCP/IP .295
TCP/IP and the Internet .297
IP addresses .297
Internet services and port numbers .298
Setting Up an Ethernet LAN .299
How Ethernet works 300
Ethernet cables 301
Configuring TCP/IP Networking .302
Connecting Your LAN to the Internet .305
Chapter 3: Adding a Wireless Ethernet LAN .307
Understanding Wireless Ethernet Networks .307
Understanding infrastructure and ad hoc modes .308
Understanding wired equivalent privacy (WEP) 310
Setting Up the Wireless Hardware .310
Configuring the wireless access point .312
Configuring Wireless Networking 312
Chapter 4: Managing the Network .319
Learning the TCP/IP Configuration Files .319
/etc/hosts 320
/etc/networks 320
/etc/host.conf 320
/etc/resolv.conf 321
/etc/hosts.allow 321
/etc/hosts.deny 322
/etc/nsswitch.conf 323
Checking Out TCP/IP Networks 323
Checking the network interfaces 323
Checking the IP routing table 324
Checking connectivity to a host .325
Checking network status .325
Sniffing network packets .327
Configuring Networks at Boot Time .328
Trang 18Table of Contents xv
Chapter 5: Cool Networking Projects .329
Building Your Own Home Network .329
Things you need .329
Steps to follow .330
Adding Wireless to Your Current Network 331
Things you need .331
Steps to follow .331
Turning Your Fedora Core System into a NAT Router 332
Things you need .332
Steps to follow .333
Book V: Internet 335
Chapter 1: Exchanging E-Mail and Instant Messages 337
Understanding Electronic Mail 338
How MUA and MTA work 338
Mail message enhancements .339
Taking Stock of Mail Readers and IM Clients in Fedora Core .340
Using Ximian Evolution .340
Using Mozilla Mail .344
Managing your Inbox .347
Composing and sending messages .348
Instant Messaging with Gaim 349
Chapter 2: Using the Web .351
Discovering the World Wide Web 351
Like a giant spider’s web .352
Links and URLs .353
Web servers and Web browsers .355
Web Browsing in Fedora Core .356
Checking out the Web browsers in Fedora Core .357
Starting Mozilla 357
Learning Mozilla’s user interface .357
Changing your home page 361
Changing Mozilla’s appearance .361
Surfing the Net with Mozilla 363
Creating Web Pages 364
Introducing HTML .364
Composing Web pages with Mozilla Composer .366
Trang 19Red Hat Fedora Linux 2 All-in-One Desk Reference For Dummies
xvi
Chapter 3: Reading Newsgroups .371
Understanding Newsgroups .371
Newsgroup hierarchy 372
Top-level newsgroup categories 373
Linux-related newsgroups .374
Reading Newsgroups from Your ISP .375
Reading newsgroups with Mozilla Mail .376
Newsgroup subscriptions .378
Posting news .379
Reading and Searching Newsgroups at Web Sites .380
Chapter 4: Transferring Files with FTP .383
Using Graphical FTP Clients .383
Using gFTP 384
Using a Web browser as an FTP client 385
Using the Command-Line FTP Client .387
Book VI: Administration 391
Chapter 1: Performing Basic System Administration .393
Taking Stock of System-Administration Tasks 393
How to Become root .395
Using the su - command .395
Becoming root for the GUI Utilities 395
Recovering from a forgotten root password 396
Understanding How Fedora Core Boots 397
Understanding the init process .397
Examining the /etc/inittab file .399
Trying a new run level with the init command 400
Understanding the Fedora Core startup scripts .401
Manually starting and stopping servers .402
Automatically starting servers at system startup .403
Understanding the GUI startup .404
Taking Stock of Fedora Core System Configuration Files .406
Monitoring System Performance .408
Using the top utility .409
Using the GNOME system monitor .411
Using the uptime command .412
Using the vmstat utility .413
Checking disk performance and disk usage 414
Viewing System Information via the /proc File System .415
Scheduling Jobs in Fedora Core .418
Scheduling one-time jobs .419
Scheduling recurring jobs .421
Trang 20Table of Contents xvii
Chapter 2: Managing Users .425
Adding User Accounts .425
Using the User Manager to add user accounts 426
Using commands to manage user accounts .428
Understanding the /etc/passwd File 429
Managing Groups .430
Exploring the User Environment 431
Changing User and Group Ownership of Files 434
Chapter 3: Managing the File System .437
Learning the Linux File System .437
Understanding the file-system hierarchy .438
Mounting a device on the file system .440
Examining the /etc/fstab file .442
Sharing Files with NFS .443
Exporting a file system with NFS .444
Mounting an NFS file system 445
Backing Up and Restoring Files 445
Selecting a backup strategy and media .445
Commercial backup utilities for Linux .447
Using the tape archiver — tar 447
Accessing DOS/Windows File Systems 452
Mounting a DOS disk partition .452
Mounting DOS floppy disks 453
Mounting an NTFS Partition 455
Using mtools .455
Trying mtools 456
Understanding the /etc/mtools.conf file .456
Learning the mtools commands .457
Formatting a DOS floppy .459
Chapter 4: Managing Applications .461
Working with Red Hat Package Manager .461
Using the RPM commands .461
Understanding RPM filenames 462
Finding out about RPMs .463
Installing an RPM .466
Removing an RPM .467
Upgrading an RPM 467
Verifying an RPM .468
Building Software Packages from Source Files .469
Downloading and unpacking the software .469
Building the software from source files 471
Installing SRPMS .474
Updating Fedora Core Applications with Up2date .474
Using Yellow dog Updater, Modified (Yum) .475
Trang 21Red Hat Fedora Linux 2 All-in-One Desk Reference For Dummies
xviii
Chapter 5: Managing Devices and Printers 479
Understanding Linux Devices .479
Device files .480
Persistent device naming with udev .482
Managing Loadable Driver Modules .482
Loading and unloading modules .483
Using the /etc/modprobe.conf file .485
Managing USB Devices .486
Managing Print Queues in Fedora Core 488
Spooling and print jobs .488
Printing with the lp command .490
Checking the print queue using lpq .490
Canceling the print job using cancel .490
Checking the printer status using lpstat .491
Controlling the print queue 491
Chapter 6: Upgrading and Customizing the Kernel 493
Upgrading with a Kernel RPM 494
Downloading new kernel RPMs .494
Installing the kernel RPMs 494
Trying out the new kernel .495
Rebuilding the Kernel .496
Creating a monolithic versus a modular kernel .497
Configuring the kernel .498
Running the kernel configuration tool 499
Building the Kernel and the Modules .513
Installing the Modules .514
Creating the Initial RAM Disk File 514
Installing the New Kernel and Setting Up GRUB .515
Rebooting the System 517
Book VII: Security .519
Chapter 1: Understanding Network and Host Security .521
Why Worry About Security? .521
Establishing a Security Framework .522
Determine business requirements for security .523
Perform risk analysis .524
Establish security policy .525
Implement security solutions (mitigation) .526
Manage security .526
Trang 22Table of Contents xix
Securing Linux .527Understanding the host security issues 527Understanding network security issues 528Learning Computer Security Terminology 529Keeping Up with Security News and Updates .532
Chapter 2: Securing the Host .535
Installing Operating System Updates .535Securing Passwords .536Shadow passwords 536Pluggable authentication modules (PAMs) .537Protecting Files and Directories 540Viewing ownerships and permissions .540Changing file ownerships .541Changing file permissions .541Setting default permission .542Checking for set user ID permission .543Using exec-shield 544Using SELinux .545Encrypting and Signing Files with GnuPG 547Understanding public-key encryption .547Understanding digital signatures .548Using GPG .550Monitoring System Security 554
Chapter 3: Securing the Network .557
Securing Internet Services .557Using chkconfig to disable standalone services .558Configuring the xinetd server to disable services .558Using Secure Shell (SSH) for Remote Logins .561Setting Up Simple Firewalls 563Screening the router with packet filtering .565Dual-homed host .567Perimeter network with bastion host .568Application gateway 570Enabling Packet Filtering on Your Fedora Core System .571Using the security level configuration tool .572Using the iptables command .573
Chapter 4: Performing Security Audits .577
Understanding Security Audits .577Nontechnical aspects of security audits .578Technical aspects of security audits .579
Trang 23Red Hat Fedora Linux 2 All-in-One Desk Reference For Dummies
xx
Learning a Security Test Methodology 579Some common computer vulnerabilities .580Host security review .582Network-security review 585Exploring Security Testing Tools .588Nmap 589Nessus 590SAINT 593SARA 594Book VIII: Internet Servers .595
Chapter 1: Managing the Servers .597
Understanding Internet Services .597TCP/IP and sockets .598Internet services and port numbers .601Using the xinetd Super Server 603Running Standalone Servers 606Starting and stopping servers manually .606Starting servers automatically at boot time .607
Chapter 2: Running the Apache Web Server .615
Exploring HTTP .615Exploring the Apache Web Server .618Installing the Apache Web server .619Starting the Apache Web server 620Configuring the Apache Web Server 621Using Apache configuration tools .622Apache configuration files .623The httpd.conf configuration file .624Virtual host setup 634
Chapter 3: Setting Up the FTP Server .639
Installing the FTP Server .639Configuring the FTP Server 640vsftpd configuration files .640/etc/vsftpd/vsftpd.conf file 641/etc/vsftpd.ftpusers file .643/etc/vsftpd.user_list file 644Setting Up Secure Anonymous FTP .644Trying Anonymous FTP 645Key features of anonymous FTP .645
Trang 24Table of Contents xxi
Chapter 4: Serving Up Mail and News .647
Installing the Mail Server .647Using sendmail 648
A mail-delivery test .649The mail-delivery mechanism 649The sendmail configuration file 651sendmail.cf file syntax .659Other sendmail files .661The forward file .662Invoking procmail in the forward file 663The sendmail alias file .664Installing the News Server .665Configuring and Starting the INN Server 665InterNetNews components 666The incoming.conf file .670The readers.conf file .671InterNetNews startup .671Setting Up Local Newsgroups 672Defining a newsgroup hierarchy 673Updating configuration files 673Adding the newsgroups .674Testing your newsgroups .674
Chapter 5: Setting Up DNS .675
Understanding Domain Name System (DNS) 675What is DNS? .676Learning hierarchical domain names .677Exploring Berkeley Internet Name Domain (BIND) 678Configuring DNS .682Configuring the resolver 682Configuring a caching name server .683Configuring a primary name server .692
Chapter 6: Running Samba and NFS .695
Sharing Files with NFS .695Exporting a file system with NFS .696Mounting an NFS file system 698Using the NFS Server Configuration tool 699Setting Up a Windows Server Using Samba .700Checking whether Samba is installed .702Configuring Samba .703Trying out Samba .705
Trang 25Red Hat Fedora Linux 2 All-in-One Desk Reference For Dummies
xxii
Book IX: Programming 707
Chapter 1: Fedora Core Programming Essentials .709
Learning Programming .709
A simplified view of a computer .710Role of the operating system .711Basics of computer programming .712Exploring the Software Development Tools in Fedora Core 713GNU C and C++ compilers .714The GNU make utility .718The GNU debugger .725Understanding the Implications of GNU Licenses .732The GNU General Public License 732The GNU Library General Public License 733
Chapter 2: Programming in C .735
The Structure of a C Program .735Preprocessor Directives .737Including files 738Defining macros .738Declaration and Definition of Variables 741Basic data types .741Enumerations 742Structures, Unions, and Bit Fields 743Arrays 743Pointers 744Type definitions .745Type qualifiers: const and volatile .746Expressions 747Operator Precedence 749Statements 751The break statement .751The case statement .752
A compound statement or block 752The continue statement .752The default label 753The do statement .753Expression statements 753The for statement .753The goto statement .754The if statement 754The if-else statement 754The null statement .755The return statement .755
Trang 26Table of Contents xxiii
The switch statement .755The while statement .756Functions 757Function prototypes 757The void type .758Functions with a variable number of arguments 758The C Library 758Shared Libraries in Linux Applications .760Examining shared libraries that a program uses .760Creating a shared library 762Dynamically loading a shared library 764
Chapter 3: Writing Shell Scripts .767
Trying Out Simple Shell Scripts .767Learning the Basics of Shell Scripting .770Storing stuff .770Calling shell functions 771Controlling the flow 772Exploring Bash’s built-in commands .775
Chapter 4: Programming in Perl 779
Understanding Perl .779Determining Whether You Have Perl 780Writing Your First Perl Script 782Getting an Overview of Perl 783Basic Perl syntax .783Variables 784Operators and expressions .787Regular expressions .789Flow-control statements .791Accessing Linux commands 795File access .797Filename with pipe prefix .798Subroutines 799Built-in functions in Perl .800Understanding Perl Packages and Modules .800Perl packages .801Perl modules .802Using a module .803Using Objects in Perl .804Understanding Perl Objects 804Creating and accessing Perl objects .805Using the English module 806
Trang 27Red Hat Fedora Linux 2 All-in-One Desk Reference For Dummies
xxiv
Appendix: About the DVD 807
DVD Installation Instructions .807What You Can Find on the DVD 809Troubleshooting 810Index 811
Trang 28Red Hat has recently decided to discontinue the Red Hat Linux productline and instead focus on the commercial Red Hat Enterprise Linux —RHEL — product line The evolution of the now-defunct Red Hat Linuxproduct line continues on as the Fedora Project, a Red Hat-sponsored andcommunity-supported open source project that continues to evolve whatonce was Red Hat Linux What comes out of the Fedora Project is a FedoraCore release every six months or so (For example, Fedora Core 1 came out
in November 2003 and Fedora Core 2 was released in May 2004.) In contrast
to the rapid Fedora Core release cycles, RHEL is a stable product line with
a 12 to 18 month release cycle and five years of support for every version.New technologies that first appear in Fedora Core will eventually find theirway into the next-generation Red Hat Enterprise Linux (RHEL) product.Thus, Fedora Core releases are a precursor to what’s coming in RHEL inthe future
The recently released Fedora Core 2 comes with many new system nents including the Linux 2.6.5 kernel, X.Org X11 6.7.0, GNOME 2.6, KDE 3.2.2,GCC 3.3 compiler, and the glibc 2.3.3 system libraries This version supportsmany new features such as Advanced Configuration and Power Interface(ACPI), Bluetooth wireless connections, and a graphical boot screen thatshows system startup messages in a user-friendly screen
compo-Fedora Core 2 also includes the OpenOffice.org 1.1.1 office suite To top itoff, Fedora Core continues to come with a graphical installation programthat makes installation easy!
About This Book
Red Hat Fedora Linux 2 All-in-One Desk Reference For Dummies gives you
nine different quick-reference guides in a single book Taken together, thesenine books provide detailed information on installing, configuring, andusing Fedora Core
What you’ll like most about this book is that you don’t have to read itsequentially chapter by chapter, or, for that matter, even the sections in
a chapter You can pretty much turn to the topic you want and quickly getthe answer to your pressing questions about Fedora Core, be it about usingthe OpenOffice.org word processor or setting up the Apache Web server
Trang 29Conventions Used in This Book
2
Here are some of the things you can do with this book:
✦ Install and configure Fedora Core from the DVD-ROM included with thebook
✦ Connect the Fedora Core PC to the Internet through a DSL or cablemodem
✦ Set up dial-up networking with PPP
✦ Get tips, techniques, and shortcuts for specific uses of Fedora Core,such as
• Setting up and using Internet services such as Web, Mail, News, FTP,NFS, and DNS
• Setting up a Windows server using Samba
• Using Linux commands
• Using Perl, shell, and C programming on Linux
• Using the OpenOffice.org office suite and other applications thatcome with Fedora Core
✦ Understand the basics of system and network security
✦ Perform system administration tasks
Conventions Used in This Book
I use a simple notational style in this book All listings, filenames, functionnames, variable names, and keywords are typeset in a monospacefont forease of reading I italicize the first occurrences of new terms and conceptsand then provide a definition right there The output of commands followsthe typed command and the output is shown in a monospace font
What You Don’t Have to Read
Each mini reference book zeros in on a specific task area such as using theInternet or running Internet servers and then provides hands-on instructions
on how to perform a series of related tasks You can jump right to a sectionand read about a specific task You don’t have to read anything but the fewparagraphs or the list of steps that relate to your question Use the Table ofContents or the Index to locate the pages relevant to your question
You can safely ignore text next to the Technical Stuff icons as well as thesidebars
Trang 30How This Book Is Organized 3
Who Are You?
I assume that you are somewhat familiar with a PC — you know how to turn
it on and off and you have dabbled a bit with Windows Considering thatmost new PCs come preloaded with Windows, this assumption is safe, right? When installing Fedora Core on your PC, you may want to retain your
Windows 2000 or Windows XP installations intact I assume you don’t
mind investing in a good disk-partitioning tool such as PowerQuest’s
PartitionMagic, available at www.powerquest.com/partitionmagic
(no, I don’t have any connections with PowerQuest)
I also assume that you are willing to accept the risk that when you try toinstall Fedora Core, some things may not quite work Problems can happen
if you have some uncommon types of hardware If you are afraid of ruiningyour system, try finding a slightly older spare Pentium PC that you can sac-rifice and then install Fedora Core on that PC
How This Book Is Organized
Red Hat Fedora Linux 2 All-in-One Desk Reference For Dummies has nine books,
each of which focuses on a small set of related topics If you are looking forinformation on a specific topic, check the book names on the spine or con-sult the Table of Contents
This desk reference starts with a minibook that explains the basics of FedoraCore and guides you through the installation process (a unique aspect ofthis book because you typically do not purchase a PC with Fedora Core pre-installed) The second minibook serves as a user’s guide to Fedora Core — itfocuses on exploring various aspects of a Fedora Core workstation, includingthe GNOME and KDE GUIs and many of the applications that come bundledwith Fedora Core The third minibook is a user’s guide to the OpenOffice.orgoffice applications The fourth minibook covers networking and Book V goesinto using the Internet Book VI introduces system administration The sev-enth minibook turns to the important subject of securing a Fedora Coresystem and its associated network Book VIII shows you how to run a vari-ety of Internet servers from mail to a Web server The ninth and final mini-book introduces you to programming
Here’s a quick overview of the nine books and what they contain:
Book I: Fedora Basics: What is Fedora Core? Understanding what’s new in
the Linux 2.6 kernel Installing, configuring, and troubleshooting FedoraCore Taking Fedora Core for a test drive
Trang 31What’s on the DVD?
4
Book II: Workstations and Applications: Exploring GNOME and KDE Using
the shell (what’s a shell anyway?) Navigating the Fedora Core file system.Exploring the applications such as multimedia software as well as the texteditors (viand ed)
Book III: OpenOffice.org: Writing with OpenOffice.org Writer Preparing
spreadsheets with OpenOffice.org Calc Making presentations with
OpenOffice.org Impress Preparing drawings with OpenOffice.org Draw
Book IV: Networking: Connecting the Fedora Core PC to the Internet through
a dial-up connection or a high-speed always-on connection such as DSL orcable modem Configuring and managing TCP/IP networks, including wire-less networks
Book V: Internet: Using various Internet services such as e-mail, Web
surf-ing, and reading newsgroups Transferring files with FTP
Book VI: Administration: Performing basic system administration Managing
user accounts and the file system Installing applications Working withdevices and printers Using USB devices Upgrading and customizing theLinux kernel
Book VII: Security: Understanding network and host security Securing the
host and the network Performing security audits
Book VIII: Internet Servers: Managing the Internet services Configuring the
Apache Web server Setting up the FTP server (including anonymous FTP).Configuring the mail and news servers Providing DNS File sharing with NFS.Using Samba to set up a Windows server
Book IX: Programming: Finding out the basics of programming Exploring the
software development tools in Fedora Core Writing shell scripts Learning Cand Perl programming
Appendix: About the DVD: Summarizes the contents of the book’s
compan-ion DVD-ROM
What’s on the DVD?
The DVD contains Fedora Core 2 from the Fedora Project (fedora.redhat.com) You may use the DVD in accordance with the license agreementsaccompanying the software To discover more about the contents of the DVD,please consult the appendix
Trang 32Where to Go from Here 5
Icons Used in This Book
Following the time-honored tradition of the All-in-One Desk Reference For
Dummies series, I use icons to help you quickly pinpoint useful information.
The icons include the following:
The Remember icon marks a general interesting fact — something that Ithought you want to know and remember
The Tip icon marks things that you can do to make your job easier
The Warning icon highlights potential pitfalls With this icon, I’m telling you:
“Watch out! This could hurt your system!”
The Technical Stuff icon marks technical information that could be of est to an advanced user (or those of us aspiring to be advanced users)
inter-Where to Go from Here
It’s time to get started on your Fedora Core adventure Take out the DVDand install Fedora Core Then, turn to a relevant chapter and let the funbegin Use the Table of Contents and the Index to figure out where you want
to go Before you know it, you’ll become an expert at Fedora Core!
If you want to participate in the Fedora Core project, visit the project’s Website at fedora.redhat.comfor more information
I hope you enjoy consulting this book as much as I enjoyed writing it!
Sidebars
I use sidebars throughout the book to highlight
interesting, but not critical, information Sidebars
explain concepts you may not have encountered
before or give a little insight into a related topic
If you’re in a hurry, you can safely skip thesidebars
Trang 33Red Hat Fedora Linux 2 All-in-One Desk Reference For Dummies
6
Trang 34Book I
Fedora Basics
Trang 35Contents at a Glance
Chapter 1: Introducing Fedora Core 9 Chapter 2: Installing Fedora 31 Chapter 3: Troubleshooting and Configuring Fedora Core 57 Chapter 4: Trying Out Fedora Core 75 Chapter 5: Cool Fedora Install Projects 99
Trang 36Chapter 1: Introducing Fedora Core
In This Chapter
Explaining what Fedora Core is
Going over what Fedora Core includes
Discovering what Fedora Core helps you manage
Getting started
Ibet you’ve heard about Linux and you probably know about Red Hat
Linux as well, but chances are Fedora Core is new to you If you’re dering what exactly Fedora Core is and what it can help you do, this chapter
won-is all about answering those questions Here I provide a broad-brushstrokepicture of Fedora Core and tell you how you can start using it right away
By the way, this book covers Fedora Core for Intel 80x86 and Pentiumprocessors (basically any PC that can run any flavor of Windows)
What Is Fedora Core?
Fedora Core is what used to be Red Hat Linux — the Linux distribution fromRed Hat that used to be available free of charge If you never knew Red HatLinux, think of Fedora Core as another Linux distribution That leaves youwith the question: What is a Linux distribution anyway?
Trying to describe a Linux distribution is a bit like that story of six blindmen trying to describe an elephant You know the one — one blind mantouches the elephant’s side and says the elephant is like a wall, anotherchecks out the tusk and concludes that an elephant is like a spear, and so
on Along those lines, a Linux distribution appears to be many differentthings, depending on what you experience You can think of it as the graph-ical user interface or just a PC to run your e-mail program, but, at its heart,it’s an operating system The following sections explain what I mean by thisstatement
Operating systems and Linux
You know that your PC is a bunch of hardware — things you can touch, like
the system box, monitor, keyboard, and mouse The system box contains
the most important hardware of all — the central processing unit (CPU), the microchip that runs the software (any program that tells the computer how
Trang 37What Is Fedora Core?
10
to do your bidding) — which you actually can’t touch In a typical Pentium 4
PC, the Pentium 4 microprocessor is the CPU Other important hardware inthe system box includes the memory (RAM chips) and the hard drive — andone program has to run all this stuff and get it to play nice: the operatingsystem
The operating system is software that manages all the hardware and runs
other software at your command You, the user, provide those commands
by clicking menus and icons or by typing some cryptic text Linux is an ating system — as are UNIX, Windows 98, Windows 2000, and Windows XP.The Linux operating system is modeled after UNIX; in its most basic, no-frills
oper-form, it also goes by the name Linux kernel.
The operating system is what gives a computer — any computer — its sonality For example, you can run Windows 98 or Windows XP on a PC —
per-and on that same PC, you can also install per-and run Linux That means, ing on which operating system is installed and running, the same PC can be
depend-a Windows 98, Windows XP, or Linux system
The primary job of an operating system is to load software (computer grams) from the hard disk (or other permanent storage) into the memoryand get the CPU to run those programs Everything you do with your com-puter is possible because of the operating system — so if the operatingsystem somehow messes up, the whole system freezes up You know howinfuriating it is when your favorite operating system — maybe even the onethat came with your PC — suddenly calls it quits just as you are about toclick the Send button after composing that long e-mail to your friend You trythe three-finger salute (pressing Ctrl+Alt+Del), but nothing happens Thenit’s time for the Reset button (provided your computer’s builders were wiseenough to include one) Luckily, that sort of thing almost never happenswith Linux — it has a reputation for being a very reliable operating system
pro-Does Linux really run on any computer?
Linux runs on many different types of computer
systems — and it does seem able to run on
nearly any type of computer Linus Torvalds and
other programmers originally developed Linux
for the Intel 80x86 (and compatible) line of
processors Nowadays, Linux is also available
for systems based on other processors — such
as those with AMD’s 64-bit AMD64 processors,
the Motorola 68000 family; Alpha AXPs; Sun
SPARCs and UltraSPARCs; Hewlett-Packard’s
HP PA-RISC; the PowerPC and PowerPC64processors; and the MIPS R4x00 and R5x00.More recently, IBM has released its own ver-sion of Linux for its S/390 mainframe This bookcovers Linux for Intel 80x86 and Pentium proces-sors (these have in common a basic physical
structure known as IA-32 architecture).
Trang 38Book I Chapter 1
What Is Fedora Core? 11
In technical mumbo jumbo, Linux is a multiuser, multitasking operating system.
All this means is that Linux enables multiple users to log in, and Linux can
run more than one program at the same time Nearly all operating systems
are multiuser and multitasking these days, but when Linux first started in
1994, multiuser and multitasking were big selling points.
Linux distributions
Fedora Core is a specific Linux distribution — essentially a package of
fea-tures Fedora Core consists of the Linux kernel (the operating system) and
a collection of applications, together with an easy-to-use GUI installation
program, called Anaconda
You find many Linux distributions, and each includes the standard Linux
operating system:
✦ The X.Org X Window System: The graphical user interface.
✦ One or more graphical desktops: Among the most popular are GNOME
and KDE
✦ A selection of applications: Linux programs come in the form of
ready-to-run software, but the source code (the commands we humans use to tell
the computer what to do, but you don’t need the source code to run the
operating system or any applications) is included, as is its documentation
Current Linux distributions include a huge selection of software — so
much that it requires multiple CD-ROMs or a single DVD-ROM (which
this book includes)
Many Linux distributions are commercial products that you can buy in
com-puter stores and bookstores If you have heard about Open Source and the
GNU (GNU’s Not UNIX) license, you may assume that no one can sell Linux
for profit Luckily for companies that sell Linux distributions, the GNU
license — also called the GNU General Public License (GPL) — does allow
commercial, for-profit distribution, but requires that the software be
dis-tributed in source-code form, and stipulates that anyone may copy and
distribute the software in source-code form to anyone else Fedora Core
is available free of charge under the GPL, which means that my publisher
may include the Fedora Core DVD-ROM with this book and you may make
as many copies of the DVD as you like
Transitioning to the Fedora Project
In late September 2003, Red Hat announced the Fedora Project — an
open-source project sponsored by Red Hat where the developer community can
participate and continue to evolve what used to be the Red Hat Linux
prod-uct The new product goes by the name Fedora Core and the project is
expected to have Fedora Core releases every four to six months Red Hat
Trang 39What Is Fedora Core?
12
continues to participate in the Fedora Project and help prepare the FedoraCore releases, but everything is done with involvement of the open sourcecommunity under a public release schedule As you may expect, Fedora Core
is available freely, just as Red Hat Linux used to be, and you can expect bookssuch as this one to include Fedora Core on DVD or CDs
Red Hat continues to sell its commercial Linux distribution — called Red HatEnterprise Linux Red Hat anticipates that new technologies and enhance-ments that first appear in Fedora Core will eventually find their way into RedHat Enterprise Linux In this way, the Fedora Project serves as an incubatorand testing ground for future Linux development
To find out more about the Fedora Project, visit fedora.redhat.com
Making sense of version numbers
Both the Linux kernel and Fedora Core have their own version numbers, not
to mention the many other software programs (such as GNOME and KDE)that come with Fedora Core The version numbers for the Linux kernel andFedora Core are unrelated, but each has particular significance
Linux-kernel version numbers
After Linux kernel version 1.0 was released on March 14, 1994, the looselyknit Linux development community adopted a version-numbering scheme
Version numbers such as 1.X.Y and 2.X.Y, where X is an even number, are considered the stable versions The last number, Y, is the patch level, which
is incremented as problems are fixed For example, 2.6.5 is a typical, stableversion of the Linux kernel Notice that these version numbers are in the
form of three integers separated by periods — Major.Minor.Patch — where
Major and Minor are numbers denoting the major and minor version
num-bers, and Patch is another number representing the patch level.
Version numbers of the form 2.X.Y with an odd X number are beta releases
for developers only; they may be unstable, so you should not adopt suchversions for day-to-day use For example, when you look at version 2.5.75 of
the Linux kernel, notice the 5 — that tells you it’s a beta release Developers
add new features to these odd-numbered versions of Linux
You can find out about the latest version of the Linux kernel online at
www.kernel.org
Fedora Core version numbers
The Fedora Core development community, led by Red Hat, assigns the Fedora
Core version numbers, such as 1 or 2 They are of the form X.Y, where X is the major version and Y the minor version Nowadays if the minor version
number is zero, it’s simply dropped — as in Fedora Core 1 and Fedora Core 2
Trang 40Book I Chapter 1
What Is Fedora Core? 13
Unlike with the Linux-kernel version numbers, no special meaning is
associ-ated with odd and even minor versions Each version of Fedora Core includes
specific versions of the Linux kernel and other major components, such as
GNOME, KDE, and various applications
The Fedora Project releases new versions of Fedora Core on a regular
basis — every six months or so For example, Fedora Core 1 came out in
November 2003 and Fedora Core 2 in May 2004 Typically, each new major
version of Fedora Core provides significant new features
Under the hood in Linux kernel 2.6
Linux kernel 2.6 includes many new features and improvements when
com-pared to its predecessor — the 2.4 kernel I highlight some of these
improve-ments in this section You may not notice many of these improveimprove-ments
because they work behind the scenes All you see is a Linux system that
simply works great!
Support for wider range of computer hardware
For starters, the 2.6 kernel has been redesigned to support computers
span-ning a wider range of hardware than before — from bare-bones embedded
microcontrollers to larger-scale servers with multiple processors
To support distinct hardware architectures of the same processor family
(such as x86), Linux 2.6 uses the concept of a subarchitecture, which refers
to the processor and the associated bus and other hardware that defines a
unique type of computer For example, most of today’s PCs are based on
what is called the PC/AT subarchitecture because these PCs are based on
the original IBM PC/AT The 2.6 kernel supports PC/AT machines as well
as other x86 subarchitectures, such as the NEC Voyager and the PC-9800
machines The bottom line is that the 2.6 kernel can run on many variations
of the x86-based machines
Linux 2.6 also supports advanced features of processors such as
hyperthread-ing, which enables a single processor to act as multiple virtual processors at
the hardware level
Better scalability
The 2.6 kernel provides better scalability for Intel x86 hardware by
support-ing advanced features such as Intel’s Physical Address Extension (PAE), which
enables many newer 32-bit x86 systems to access up to 64GB of memory
Linux 2.6 also provides better handling of interrupts for multiprocessor
sys-tems through improved support for Intel’s Input/Output (I/O) Advanced
Programmable Interrupt Controller (APIC)