.117 5 First Steps with Fedora 119 Working with the Linux File System.. .845Using the C Programming Project Management Tools Provided with Fedora Core Linux.. His particular area of expe
Trang 3All rights reserved No part of this book shall be reproduced, stored in a
retrieval system, or transmitted by any means, electronic, mechanical,
photo-copying, recording, or otherwise, without written permission from the
publisher No patent liability is assumed with respect to the use of the
infor-mation contained herein Although every precaution has been taken in the
preparation of this book, the publisher and authors assume no responsibility
for errors or omissions Nor is any liability assumed for damages resulting
from the use of the information contained herein.
International Standard Book Number: 0-672-32929-8
Printed in the United States of America
First Printing: December 2006
Trademarks
All terms mentioned in this book that are known to be trademarks or service
marks have been appropriately capitalized Sams Publishing cannot attest to
the accuracy of this information Use of a term in this book should not be
regarded as affecting the validity of any trademark or service mark.
Red Hat is a registered trademark and Fedora is a trademark of Red Hat, Inc.
Warning and Disclaimer
Every effort has been made to make this book as complete and as accurate as
possible, but no warranty or fitness is implied The information provided is
on an “as is” basis The authors and the publisher shall have neither liability
nor responsibility to any person or entity with respect to any loss or damages
arising from the information contained in this book or from the use of the
CDs or programs accompanying it.
Bulk Sales
Sams Publishing offers excellent discounts on this book when ordered in
quantity for bulk purchases or special sales For more information, please
Includes bibliographical references and index.
ISBN 0-672-32929-8 (pbk w/dvd : alk paper) 1 Linux 2 Operating
systems (Computers) I Hudson, Paul, 1979- II Title
Trang 4The Safari®Enabled icon on the cover of your favorite technology bookmeans the book is available through Safari Bookshelf When you buy thisbook, you get free access to the online edition for 45 days.
Safari Bookshelf is an electronic reference library that lets you easily search thousands oftechnical books, find code samples, download chapters, and access technical informationwhenever and wherever you need it
To gain 45-day Safari Enabled access to this book:
• Go to http://www.samspublishing.com/safarienabled
• Complete the brief registration form
If you have difficulty registering on Safari Bookshelf or accessing the online edition,please email customer-service@safaribooksonline.com
Trang 5Introduction .1
Part I Installation and Configuration 1 Introducing Fedora .13
2 Preparing to Install Fedora .27
3 Installing Fedora .53
4 Post-Installation Configuration .83
5 First Steps with Fedora .119
Part II Desktop Fedora 6 The X Window System .165
7 Managing Software .191
8 On the Internet: Surfing the Web, Writing Email, and Reading the News .209
9 Productivity Applications .239
10 Multimedia Applications .261
11 Graphics Manipulation .285
12 Printing with Fedora .299
13 Games .313
Part III System Administration 14 Managing Users .325
15 Automating Tasks .351
16 System Resources .413
17 Backing Up, Restoring, and Recovery .423
18 Network Connectivity .455
19 Remote Access with SSH and Telnet .507
20 Xen .515
Part IV Fedora As a Server 21 Apache Web Server Management .523
22 Administering Database Services .567
23 File and Print .593
Trang 627 Managing DNS .701
28 LDAP .741
29 News Servers .751
Part V Programming Linux 30 Using Perl .767
31 Working with Python .789
32 Writing PHP Scripts .809
33 C/C++ Programming Tools for Fedora .843
34 Mono .859
Part VI Fedora Housekeeping 35 Securing Your Machines .873
36 Performance Tuning .885
37 Command Line Masterclass .899
38 Advancedyum .925
39 Managing the File System .935
40 Kernel and Module Management .973
Part VII Appendix A Fedora and Linux Internet Resources .999
Index .1011
Trang 7Introduction 1
What Is Fedora? .15
Inside Fedora Core .15
Features of the Fedora Install .18
Fedora File System Features .18
Fedora for Business .20
Fedora in Your Home .21
64-Bit Fedora .22
Fedora on the PPC Platform .22
Fedora on Dual-Core Machines .23
Getting the Most from Fedora and Linux Documentation .23
Fedora Developers and Documentation .25
Reference .26
2 Preparing to Install Fedora 27 Planning Your Fedora Deployment .28
Business Considerations .28
System Considerations .30
User Considerations .31
A Predeployment Planning Checklist .32
Planning the Installation .33
Hardware Requirements .33
Meeting the Minimum Fedora Core Hardware Requirements .34
Using Legacy Hardware .34
Planning for Hard Drive Storage for Your Fedora Installation Class .35
Checking Hardware Compatibility .36
Preparing for Potential Hardware Problems .37
Preparing and Using a Hardware Inventory .40
Preparing for the Install Process .43
Preparing to Install from a CD-ROM .45
Trang 8Hosting Parts of the Linux File System on Separate Partitions .47
Using Fedora’s kickstartInstallation Method .48
Reference .51
3 Installing Fedora 53 Before You Begin the Installation .53
Research Your Hardware Specifications .53
Choose an Installation Type .54
Choose Software Installation Options .54
Planning Partition Strategies .55
The Boot Loader .56
Choosing How to Install Fedora .57
Installing from CD or DVD .57
Installing Using a Network .58
Step-by-Step Installation .59
Starting the Install .60
Partitioning Your Hard Drive .66
Choosing, Configuring, and Installing the Boot Loader .68
Network Configuration .70
Setting the Time Zone .71
Creating a Root Password and User Accounts .73
Software Selection and Installation .74
Finishing the Install .76
firstbootConfiguration .78
Logging In and Shutting Down .81
Reference .82
4 Post-Installation Configuration 83 Troubleshooting Post-Installation Configuration Problems .83
Your Hardware and Kudzu .84
Pointer and Keyboard Configuration .86
Configuring Keyboards with Linux .86
Configuring Pointing Devices in Fedora .90
Configuring Display Graphics .94
Configuring Sound Devices .96
Detecting and Configuring a Modem .97
Configuring a Serial-Port Modem .98
Configuring a Fax Modem .101
Configuringminicomfor Modem Use .101
Trang 9Configuring Power Management in Fedora .102
Resetting the Date and Time .105
Using the dateCommand .105
Using the hwclockCommand .105
Using the system-config-dateClient .106
Managing PCMCIA .107
Using PCMCIA .107
Controlling PCMCIA Service .109
Configuring and Using CD, DVD, and CD-RW Drives .109
Checking Drive Assignment .110
Initializing FireWire CD Drives .111
Configuring Wireless Networks .114
Reference .117
5 First Steps with Fedora 119 Working with the Linux File System .120
Viewing the Linux File System .121
Use Essential Commands from the /binand/sbinDirectories .123
Store the Booted Kernel and View Stored Devices in the /bootand/devDirectories .124
Use and Edit Files in the /etcDirectory .124
Protect the Contents of User Directories—/home .129
Use the Contents of the /procDirectory to Interact with the Kernel .129
Work with Shared Data in the /usrDirectory .131
Temporary File Storage in the /tmpDirectory .131
Access Variable Data Files in the /varDirectory .131
Logging In to and Working with Linux .131
Text-Based Console Login .132
Working with Virtual Consoles .132
Using Simple Keyboard and Mouse Techniques in a Linux Console Session .133
Logging Out .135
Logging In and Out from a Remote Computer .135
Changing Your User Information .137
Reading Documentation .138
Using Man Pages .139
Finding and Reading Software Package Documentation .139
Using the Shell .140
Using Environment Variables .142
Trang 10Managing Files with the Shell .145
Compressing and Decompressing Files Through the Shell .146
Using the Text Editors .147
Working with vi .148
Working with emacs .149
Working with Permissions .151
Assigning Permissions .152
Directory Permissions .153
Understanding Set User ID and Set Group ID Permissions .155
Working As Root .156
Creating Users .157
Deleting Users .158
Shutting Down the System .158
Rebooting the System .159
Reference .160
Part II Desktop Fedora 6 The X Window System 165 Basic X Concepts .166
Using X .167
Elements of the xorg.confFile .168
Configuring X .173
Starting X .177
Using a Display Manager .177
Starting X from the Console by Using startx .180
Selecting and Using Window Managers .181
Using Fedora’s switchdesk .182
The Tab Window Manager .183
The Motif Window Manager .184
AIGLX—Eye Candy for the Masses .185
The GNOME and KDE Desktop Environments .186
GNOME: The GNU Network Object Model Environment .186
KDE: The K Desktop Environment .188
Reference .189
7 Managing Software 191 Using RPM for Software Management .191
Command-Line and Graphical RPM Clients .193
Usingrpmon the Command Line .195
Package Organization with RPM .197
Extracting a Single File from an RPM File .198
Trang 11Alternatives for Software Management .200
yum .201
pup .202
Compiling Software from Source .203
Buildingrpmsfromsrc.rpmFiles .203
Working with Source RPM Files .204
Compile from Source Tarballs .206
Reference .208
8 On the Internet: Surfing the Web, Writing Email, and Reading the News 209 Choosing a Web Browser .209
Mozilla Firefox .210
The Mozilla Suite .211
Epiphany .212
Konqueror .212
Choosing an Email Client .213
Evolution .215
Mozilla Thunderbird .217
Balsa .217
KMail .219
Mozilla Mail .219
ThemailApplication .220
mutt .222
Other Mail Clients .224
An Overview of Network News .224
Newsgroups .225
Selecting a Newsreader .226
TheslrnNews Client .226
The Pan News Client .226
The KNode News Client .228
The Mozilla News Client .229
The Thunderbird News Client .231
RSS Readers .231
Firefox .231
Blam .231
Collaborating with TWiki .232
Internet Relay Chat .234
Internet Messaging with GAIM .236
Videoconferencing with Ekiga .236
Trang 129 Productivity Applications 239
Office Suites for Fedora .240
Working with OpenOffice.org .241
Working with OpenOffice.org Writer .244
Working with OpenOffice.org Calc .247
Working with Gnome Office .252
Working with KOffice .255
Productivity Applications Written for Microsoft Windows .259
Reference .260
10 Multimedia Applications 261 Burning CDs and DVDs in Fedora Core Linux .262
Creating CDs from the Command Line .263
Creating DVDs from the Command Line .265
Creating CDs and DVDs with Fedora’s Graphical Clients .267
Sound and Music .270
Sound Cards .271
Recording Sound .271
Sound Formats .271
Music Players .273
Streaming Audio .274
Viewing TV and Video .275
TV and Video Hardware .275
Video Formats .277
Viewing Video in Linux .278
Viewing Television with Linux .279
Personal Video Recorders .280
DVD and Video Players .281
Reference .283
11 Graphics Manipulation 285 Graphics Manipulation .285
The GNU Image Manipulation Program .285
Using Digital Cameras with Fedora .287
Webcams .287
Handheld Digital Cameras .288
Using F-Spot .290
Using Scanners in Fedora .292
Working with Graphics Formats .293
Capturing Screen Images .296
Trang 1312 Printing with Fedora 299
Overview of Fedora Printing .299
Configuring and Managing Print Services .301
GUI-Based Printer Configuration Quickstart .302
Console-Based Printer Configuration Quickstart .303
Managing Printing Services .303
Creating and Configuring Local Printers .305
Creating the Print Queue .306
Editing Printer Settings .310
Reference .311
13 Games 313 Linux Gaming .313
Installing Proprietary Video Drivers .314
Installing DOOM 3 .315
Installing Unreal Tournament 2004 .317
Installing Quake 4 .318
Installing Wolfenstein: Enemy Territory .319
Battle of Wesnoth .319
KDEedu .320
Playing Windows Games with Cedega .321
Reference .322
Part III System Administration 14 Managing Users 325 User Accounts .325
User IDs and Group IDs .327
File Permissions .327
Managing Groups .328
Group Management Tools .330
Managing Users .332
User Management Tools .332
Adding New Users .334
Monitoring User Activity on the System .335
Managing Passwords .336
System Password Policy .336
The Password File .336
Shadow Passwords .338
Managing Password Security for Users .340
Trang 14Granting System Administrator Privileges to Regular Users .341
Temporarily Changing User Identity with the suCommand .341
Granting Root Privileges on Occasion—The sudoCommand .343
Control Via Restricted Shells .346
The User Login Process .346
Disk Quotas .348
Implementing Quotas .348
Manually Configuring Quotas .349
Reference .350
15 Automating Tasks 351 Running Services at Bootup .352
Beginning the Boot Loading Process .352
Loading the Linux Kernel .353
System Services and Runlevels .354
Runlevel Definitions .355
Booting into the Default Runlevel .356
Booting to a Nondefault Runlevel with GRUB .358
UnderstandinginitScripts and the Final Stage of Initialization .359
Controlling Services at Boot with Administrative Tools .360
Running Services Through xinetd .363
Changing Runlevels .364
Troubleshooting Runlevel Problems .365
Starting and Stopping Services Manually .366
Scheduling Tasks .367
Usingatandbatchto Schedule Tasks for Later .367
Usingcronto Run Jobs Repeatedly .369
Basic Shell Control .372
The Shell Command Line .373
Shell Pattern-Matching Support .374
Redirecting Input and Output .375
Piping Data .376
Background Processing .377
Writing and Executing a Shell Script .377
Running the New Shell Program .379
Storing Shell Scripts for Systemwide Access .380
Interpreting Shell Scripts Through Specific Shells .380
Using Variables in Shell Scripts .382
Assigning a Value to a Variable .382
Accessing Variable Values .383
Trang 15A Simple Example of a Positional Parameter .383
Using Positional Parameters to Access and Retrieve Variables from the Command Line .384
Using a Simple Script to Automate Tasks .384
Built-in Variables .387
Special Characters .387
Use Double Quotes to Resolve Variables in Strings with Embedded Spaces .388
Using Single Quotes to Maintain Unexpanded Variables .389
Using the Backslash As an Escape Character .390
Using the Backtick to Replace a String with Output .390
Comparison of Expressions in pdkshandbash .390
Comparing Expressions with tcsh .396
TheforStatement .400
ThewhileStatement .401
TheuntilStatement .403
TherepeatStatement (tcsh) .404
TheselectStatement (pdksh) .404
TheshiftStatement .405
TheifStatement .405
ThecaseStatement .407
ThebreakandexitStatements .408
Using Functions in Shell Scripts .409
Reference .410
16 System Resources 413 System-Monitoring Tools .413
Console-Based Monitoring .413
Using the killCommand to Control Processes .415
Using Priority Scheduling and Control .416
Displaying Free and Used Memory with free .418
Disk Quotas .418
Graphical Process- and System Management Tools .419
KDE Process- and System-Monitoring Tools .422
Reference .422
17 Backing Up, Restoring, and Recovery 423 Choosing a Backup Strategy .423
Why Data Loss Occurs .424
Assessing Your Backup Needs and Resources .425
Evaluating Backup Strategies .427
Trang 16Choosing Backup Hardware and Media .430
Removable Storage Media .430
Network Storage .431
Tape Drive Backup .432
Using Backup Software .432
tar:The Most Basic Backup Tool .433
The GNOME File Roller .435
The KDE Archiving Tools (KDE arkandkdat) .435
Using the ddCommand for Archiving .437
Using the Amanda Backup Application .438
Alternative Backup Software .438
Copying Files .439
Copying Files Using tar .439
Compressing, Encrypting, and Sending tarStreams .440
Copying Files Using cp .441
Copying Files Using mc .441
Copying Files Using scp .442
Copying Files Using rsync .444
Undeleting Files .446
Reformatting with the -SOption When Experiencing Unrecoverable File System Errors .446
Undeleting Files Using mc .446
System Rescue .447
The Fedora Rescue Disc .448
Backing Up and Restoring the Master Boot Record .448
Manually Restoring the Partition Table .448
Booting the System from the Rescue Disc .449
Booting the System from a Generic Boot Floppy Disk .450
Using a GRUB Boot Floppy Disk .450
Using the Recovery Facility from the Installation Disc .451
Reference .453
18 Network Connectivity 455 Laying the Foundation: The localhostInterface .455
Checking for the Availability of the Loopback Interface .456
Configuring the Loopback Interface Manually .456
Networking with TCP/IP .457
TCP/IP Addressing .458
Using IP Masquerading in Fedora .460
Ports .461
Trang 17Network Organization .462
Subnetting .462
Subnet Masks .462
Unicast, Multicast, and Broadcast Addressing .463
Hardware Devices for Networking .463
Network Interface Cards .463
Network Cable .466
Hubs and Switches .467
Routers and Bridges .468
Initializing New Network Hardware .468
Using Network Configuration Tools .471
Command-Line Network Interface Configuration .472
Network Configuration Files .476
Using Graphical Configuration Tools .479
Dynamic Host Configuration Protocol .481
How DHCP Works .481
Activating DHCP at Installation and Boot Time .482
DHCP Software Installation and Configuration .483
Using DHCP to Configure Network Hosts .484
Other Uses for DHCP .487
Wireless Networking .487
Support for Wireless Networking in Fedora .487
Cellular Networking .488
Advantages of Wireless Networking .489
Choosing from Among Available Wireless Protocols .489
Beyond the Network and onto the Internet .490
Common Configuration Information .491
Configuring Digital Subscriber Line Access .492
Understanding Point-to-Point Protocol over Ethernet .493
Configuring a PPPoE Connection Manually .493
Configuring Dial-Up Internet Access .495
Configuring a Dial-Up Connection Manually .495
Using the Fedora Internet Configuration Wizard .498
Troubleshooting Connection Problems .501
Configuring a Dial-In PPP Server .502
Using Patches/Upgrades to Keep Your Network Secure .505
Reference .505
General .505
DHCP .505
Wireless .506
Trang 1819 Remote Access with SSH and Telnet 507
Setting Up a Telnet Server .507
Telnet Versus SSH .508
Setting Up an SSH Server .508
The SSH Tools .509
Usingscpto Copy Individual Files Between Machines .510
Usingsftpto Copy Many Files Between Machines .510
Usingssh-keygento Enable Key-Based Logins .511
Remote X .512
XDMCP .513
VNC .514
Reference .514
20 Xen 515 Why Virtualization Is a Smart Idea .515
Virtualization Versus Paravirtualization .516
How Xen Works .517
Installing Xen .517
Setting Up Guest Operating Systems .518
Runtime Configuration .519
Reference .520
Part IV Fedora As a Server 21 Apache Web Server Management 523 About the Apache Web Server .523
Installing the Apache Server .525
Installing from the RPM .525
Building the Source Yourself .527
Starting and Stopping Apache .530
Starting the Apache Server Manually .530
Using/etc/rc.d/init.d/httpd .531
Controlling Apache with Red Hat’s serviceCommand .533
Controlling Apache with Red Hat’s chkconfigCommand .533
Controlling Apache with Red Hat’s system-config-services Client .534
Runtime Server Configuration Settings .535
Runtime Configuration Directives .535
Editinghttpd.conf .536
Apache Multiprocessing Modules .538
Trang 19File System Authentication and Access Control .541
Restricting Access with allowanddeny .541
Authentication .542
Final Words on Access Control .545
Apache Modules .545
mod_access .546
mod_alias .546
mod_asis .546
mod_auth .547
mod_auth_anon .547
mod_auth_dbm .547
mod_auth_digest .547
mod_autoindex .548
mod_cgi .548
mod_dirandmod_env .548
mod_expires .548
mod_headers .548
mod_include .549
mod_infoandmod_log_config .549
mod_mimeandmod_mime_magic .549
mod_negotiation .549
mod_proxy .549
mod_rewrite .549
mod_setenvif .550
mod_speling .550
mod_status .550
mod_ssl .550
mod_unique_id .550
mod_userdir .550
mod_usertrack .550
mod_vhost_alias .550
Virtual Hosting .551
Address-Based Virtual Hosts .551
Name-Based Virtual Hosts .552
Logging .553
Dynamic Content .555
CGI .555
SSI .556
Basic SSI Directives .557
Flow Control .561
Trang 20Graphic Interface Configuration of Apache .561
Configuring Virtual Host Properties .562
Configuring the Server .563
Configuring Apache for Peak Performance .564
Other Web Servers for Use with Fedora .564
Sun Java System Web Server .564
Stronghold .565
Zope .565
Zeus Web Server .565
Reference .566
22 Administering Database Services 567 A Brief Review of Database Basics .568
How Relational Databases Work .569
Understanding SQL Basics .571
Creating Tables .571
Inserting Data into Tables .573
Retrieving Data from a Database .573
Choosing a Database: MySQL Versus PostgreSQL .575
Speed .576
Data Locking .576
ACID Compliance in Transaction Processing to Protect Data Integrity .577
SQL Subqueries .577
Procedural Languages and Triggers .578
Configuring MySQL .578
Setting a Password for the MySQL Root User .579
Creating a Database in MySQL .579
Granting and Revoking Privileges in MySQL .580
Configuring PostgreSQL .581
Initializing the Data Directory in PostgreSQL .582
Creating a Database in PostgreSQL .583
Creating Database Users in PostgreSQL .584
Deleting Database Users in PostgreSQL .584
Granting and Revoking Privileges in PostgreSQL .585
Database Clients .586
SSH Access to a Database .586
Local GUI Client Access to a Database .587
Web Access to a Database .588
The MySQL Command-Line Client .588
Trang 21The PostgreSQL Command-Line Client .590
Graphical Clients .591
Reference .592
23 File and Print 593 Using the Network File System .593
Installing and Starting or Stopping NFS .594
NFS Server Configuration .594
NFS Client Configuration .596
Putting Samba to Work .597
Manually Configuring Samba with /etc/samba/smb.conf .598
Testing Samba with the testparmCommand .601
Starting the smbdDaemon .601
Mounting Samba Shares .602
Configuring Samba Using SWAT .603
Network and Remote Printing with Fedora .608
Creating Network Printers .608
Enabling Network Printing on a LAN .608
Session Message Block Printing .611
Network-Attached Printer Configuration and Printing .612
Console Print Control .613
Console-Based Printer Configuration .613
Using Basic Print Commands .614
Managing Print Jobs .615
Using the Common UNIX Printing System GUI .616
Creating a CUPS Printer Entry .618
Avoiding Printer Support Problems .621
All-in-One (Print/Fax/Scan) Devices .621
Using USB and Legacy Printers .622
Reference .623
24 Remote File Serving with FTP 625 Using FTP Clients .625
The FTP Client Interface .626
Using the Text-Based FTP Client Interface .626
Using Graphical FTP Clients .633
FTP Servers .636
Choosing an Authenticated or Anonymous Server .637
Fedora FTP Server Packages .637
Other FTP Servers .637
Trang 22The FTP User .639
xinetdConfiguration for wu-ftpd .641Configuringxinetdfor the wu-ftpServer .641Starting the Very Secure FTP Server (vsftpd) Package .642Configuring the Very Secure FTP Server .643Controlling Anonymous Access .643OthervsftpdServer Configuration Files .644Configuring the wu-ftpdServer .646Using Commands in the ftpaccessFile to Configure wu-ftpd .647Configure Access Control .647Configure User Information .650Configure System Logging .654Configure Permission Control .655Configure Commands Directed Toward the cdpath .657Structure of the shutdownFile .658Configure FTP Server File-Conversion Actions .658Strip Prefix .659Strip Postfix .659Add-On Prefix .659Add-On Postfix .659External Command .660Types .660Options .660Description .660
An Example of Conversions in Action .660Using Commands in the ftphostsFile to Allow or Deny
FTP Server Connection .661Server Administration .662Display Information About Connected Users .662Count the Number of Connections .664Use/usr/sbin/ftpshutto Schedule FTP Server Downtime .664Use/var/log/xferlogto View a Log of Server Transactions .666Reference .667
How Email Is Sent and Received .669The Mail Transport Agent .670Choosing an MTA .672The Mail Delivery Agent .673The Mail User Agent .673
Trang 23Basic Sendmail Configuration and Operation .674Configuring Masquerading .675Using Smart Hosts .675Setting Message Delivery Intervals .676Building the sendmail.cfFile .676Mail Relaying .677Forwarding Email with Aliases .677Rejecting Email from Specified Sites .678Introducing Postfix .679Making the Switch .679Using Fetchmail to Retrieve Mail .680Installing Fetchmail .681Configuring Fetchmail .681Choosing a Mail Delivery Agent .684Procmail .685Spamassassin .685Squirrelmail .685Virus Scanners .686Special Mail Delivery Agents .686Mail Daemons .686Alternatives to Microsoft Exchange Server .687Microsoft Exchange Server/Outlook Client .687CommuniGate Pro .688Oracle Collaboration Suite .688Open Xchange .688Conclusion .688Reference .689Web Resources .689Books .690
What Is a Proxy Server? .691Installing Squid .692Configuring Clients .692Access Control Lists .693Specifying Client IP Addresses .698Sample Configurations .699Reference .700
Trang 2427 Managing DNS 701
Configuring DNS for Clients .702Understanding the /etc/host.confFile .703Understanding the /etc/nsswitch.confFile .703Understanding the /etc/hostsFile .704Understanding the /etc/resolv.confFile .705Understanding the Changes Made by DHCP .705Essential DNS Concepts .706How Nameservers Store DNS Structure Information .707How DNS Provides Name Service Information to Users .707Name Resolution in Practice .708Using DNS Tools .708
dig .709
host .710
nslookup .710
whois .710Configuring a Local Caching Nameserver .713Your Own Domain Name and Third-Party DNS .714Providing DNS for a Real Domain with BIND .715
rndc.conf .717
named.conf .717Logging .722Resolver Configuration .723Running the namedNameserver Daemon .724Providing DNS for a Real Domain .725Forward Zone .725Reverse Zone .727Registering the Domain .728Troubleshooting DNS .728Delegation Problems .729Reverse Lookup Problems .729Maintaining Accurate Serial Numbers .730Troubleshooting Problems in Zone Files .730Tools for Troubleshooting .731Using Fedora’s BIND Configuration Tool .731Managing DNS Security .733UNIX Security Considerations .733DNS Security Considerations .734Using DNS Security Extensions .737Using Split DNS .738
Trang 2528 LDAP 741
Configuring the Server .742Populating Your Directory .744Configuring Clients .747Evolution .747Thunderbird .748Administration .748Reference .749
Types of News Servers .751Full Newsfeed Servers .752Leaf Node Servers .752Local News Servers .753The INN Package and Configuration Files .753Installing the INN Package .755Configuringinnd .755Theinn.confFile .755Theincoming.confFile .757Thestorage.confFile .757Thereaders.confFile .758TheactiveandnewsgroupsFiles .760ThehistoryFiles .761Runninginnd .762Reference .763
Trang 26Conditional Statements: if/elseandunless .774
if .775
unless .775Looping .776
for .776
foreach .776
while .777
until .777
lastandnext .777
do whileanddo until .778Regular Expressions .778Access to the Shell .779Modules and CPAN .780Code Examples .781Sending Mail .781Purging Logs .783Posting to Usenet .784One-Liners .784Command-Line Processing .785Reference .786Books .786Usenet .787WWW .787Other .788
Python on Linux .789Getting Interactive .790The Basics of Python .791Numbers .791More on Strings .792Lists .795Dictionaries .797Conditionals and Looping .798Functions .800Object Orientation .801Class and Object Variables .802Constructors and Destructors .803Class Inheritance .804Multiple Inheritance .805The Standard Library and the Vaults of Parnassus .806
Trang 2732 Writing PHP Scripts 809
Introduction to PHP .810Entering and Exiting PHP Mode .810Variables .810Arrays .812Constants .813References .814Comments .815Escape Sequences .815Variable Substitution .816Operators .817Conditional Statements .819Special Operators .821Switching .821Loops .823Including Other Files .826Basic Functions .826Strings .826Arrays .830Files .832Miscellaneous .834Handling HTML Forms .837Databases .838Introduction to PEAR::DB .838Reference .840
Programming in C with Linux .843Programming in C++ .844Getting Started with Linux C/C++ Programming .844The Process of Programming .845Elements of the C/C++ Language .845Using the C Programming Project Management Tools
Provided with Fedora Core Linux .846Building Programs with make .846Using the autoconfUtility to Configure Code .848Managing Software Projects with RCS and CVS .849Debugging Tools .850Using the GNU C Compiler .852
Trang 28Graphical Development Tools .853Using the KDevelop Client .853Trolltech’s Qt Designer .854The Glade Client for Developing in GNOME .855Additional Resources .857Reference .858
Why Use Mono? .859Mono on the Command Line .860The Structure of a C# Program .862Printing Out the Parameters .863Creating Your Own Variables .863Adding Some Error Checking .864Building on Mono’s Libraries .865Searching with Beagle .865Creating a GUI with Gtk# .868Reference .869Books .870
Understanding Computer Attacks .873Assessing Your Vulnerability .875Protecting Your Machine .876Securing a Wireless Network .876Passwords and Physical Security .877Configuring and Using Tripwire .878Devices .879Viruses .880Configuring Your Firewall .881Forming a Disaster Recovery Plan .882Keeping Up-to-Date on Linux Security Issues .884Reference .884
Hard Disk .885Using the BIOS and Kernel to Tune the Disk Drives .886ThehdparmCommand .886
Trang 29Themke2fsCommand .888Thetune2fsCommand .889Thee2fsckCommand .889ThebadblocksCommand .889Disabling File Access Time .889Kernel .890Apache .891MySQL .893Measuring Key Buffer Usage .893Using the Query Cache .894Miscellaneous Tweaks .896Query Optimization .896Reference .897
Why Use the Shell? .900Basic Commands .901Printing the Contents of a File with cat .902Changing Directories with cd .903Changing File Access Permissions with chmod .905Copying Files with cp .905Printing Disk Usage with du .906Finding Files by Searching with find .907Searching for a String in Input with grep .909Paging Through Output with less .910Creating Links Between Files with ln .912Finding Files from an Index with locate .914Listing Files in the Current Directory with ls .914Reading Manual Pages with man .916Making Directories with mkdir .916Moving Files with mv .917Listing Processes with ps .917Deleting Files and Directories with rm .918Printing the Last Lines of a File with tail .918Printing Resource Usage with top .919Printing the Location of a Command with which .920Combining Commands .920Multiple Terminals .922Reference .924Books .924
Trang 3038 Advanced yum 925
Getting Started .926RunningyumNoninteractively .927Usingyumto Remove Packages .928Maintainingyum .928Usingyumto Manage Package Inventory .929Configuringyum .931Creating a Local yumRepository .932Usingcreaterepo .933Reference .934
The Fedora File System Basics .935Physical Structure of the File System on the Disk .936File System Partitions .938Network and Disk File Systems .938Viewing Your System’s File Systems .940Working with the ext3File System .940Understanding the ext3File System Structure .941Journaling Options in ext3 .942Verifying File Integrity in ext3File Systems with
thefsckUtility .943Other File Systems Available to Fedora .944The Reiser File System (reiserfs) .944
JFSandXFSFile Systems .944DOS File Systems .945CD-ROM File Systems .945Creating a File System .945The Disk as a Storage Device .946Creating the Partition Table .947Creating the File System on the Partitioned Disk .950Creating a DOS File System with mkdosfs .952Mounting File Systems .953ThemountCommand .954TheumountCommand .955Mounting Automatically with /etc/fstab .955GUI Tools to Mount File Systems .957Relocating a File System .959Installing the New Drive .959Creating the Partition Table and Formatting the Disk .960Mount the New Partition and Populating It with
Trang 31Logical Volume Management .961File System Manipulation .962Creating a File System for Testing .962Mounting a Partition as Read-Only on a Running System .964Converting an Existing ext2File System to ext3 .965Examine an initrdImage File .966Managing Files for Character Devices, Block Devices,
and Special Devices .967Naming Conventions Used for Block and Character Devices .969Usingmknodto Create Devices .969Reference .970
The Linux Kernel .974The Linux Source Tree .974Types of Kernels .977Managing Modules .978When to Recompile .980Kernel Versions .981Obtaining the Kernel Sources .982Patching the Kernel .983Compiling the Kernel .984Usingxconfigto Configure the Kernel .989Creating an Initial RAM Disk Image .992When Something Goes Wrong .992Errors During Compile .993Runtime Errors, Boot Loader Problems, and Kernel Oops .994Reference .995
Websites and Search Engines .1000Web Search Tips .1000Google Is Your Friend .1001Fedora Package Listings .1001Certification .1002Commercial Support .1002Documentation .1003Linux Guides .1003
Trang 32Red Hat Linux .1004Mini-CD Linux Distributions .1004Floppy-Based Linux Distributions .1005Various Intel-Based Linux Distributions .1005PowerPC-Based Linux Distributions .1005Linux on Laptops and PDAs .1006The X Window System .1006Usenet Newsgroups .1006Mailing Lists .1008Fedora Project Mailing Lists .1008Red Hat Mailing Lists .1009Internet Relay Chat .1009
Trang 33Andrew Hudson is a regular contributor to Linux Format magazine, the UK’s largest Linux
magazine His particular area of expertise is Red Hat–based distributions, including RedHat Enterprise Linux and The Fedora Project, having worked with the original Red HatLinux since version 5 Seemingly obsessed with performance, he spends many an eveningtrying to squeeze more performance out of legacy hardware Andrew lives in Wiltshire,England, with his wife Bernice and son John Andrew does not like Emacs Andrew can becontacted at andy.hudson@gmail.com
Paul Hudson is a recognized expert in open-source technologies He is a professional
developer and full-time journalist for Future Publishing His articles have appeared in Mac Format, PC Answers, PC Format, PC Plus, and Linux Format Paul is passionate about Free
Software in all its forms and uses a mix of Linux and BSD to power his desktops andservers Paul likes Emacs Paul can be contacted through http://hudzilla.org
Trang 34To Mum and Dad, for all their love, help, and support—Paul
To my wife Bernice, who grows more beautiful every day—Andrew
Internet
Vanessa Evans is one of the most organized individuals I know, and her ability to answernearly any query relating to the publishing of the book is unbelievable She has beenextremely patient with a Brit trying to navigate through the Web that is the U.S taxsystem and I thank her for all her help and assistance
A little closer to home and I’d like to thank the Computer Services department at FuturePublishing, of which I am a part They gave me access to many different hardware config-urations allowing me to thoroughly test a lot of the material in this book Particularlymentions go to Avi Abadi, Jon Moore, and Derek Smith, all of whom have helped mealong the way
My own family has been incredibly supportive of my writing this book Juggling a bookand being a full-time father and husband is no mean feat, but thankfully I have a lovingwife in Bernice who has allowed me to shut myself away for days at a time to get thisbook completed Our young son John is a constant source of amazement and joy and hekeeps me firmly rooted to the ground
Finally I want to thank God for the many blessings He has given me My life would not
be anything without Him, and I am eternally grateful for His grace
Trang 35many years of writing, refining, testing, rewriting, exploration, and passion from manypeople I feel lucky to be part of the team and want to thank the others for their enthusi-asm and humor—it makes a huge difference to know that everyone who works on thisbook enjoys the topic!
I’m grateful to the entire team at Pearson for their help and feedback, particularly Damon,Dallas, and Mike—it’s great to work with people who really care about free software andwant to help others along that same journey Of course, Andrew and I both owe a hugedebt to our good friend Hoyt Duff, who we hope is somewhere sunny buffing up a classiccar!
My family’s contribution to this work has been immense Andrew was brave in acceptingthe job of co-writing, but it turns out that we work in tandem very well—he has done amarvelous job, and we are both very proud of this end result My wife, Ildiko, managed
to put up with even more months of me doing no housework, although I think that theminute I am finished with this it is back to the grindstone for me (why do you thinkthese acknowledgements are so long?) My parents have been immensely supportivethroughout, and I love them dearly
Finally, none of this work would have been possible without the grace of God Andrewand I have been blessed to be able to write this book, and I pray it blesses you even more
Trang 36As the reader of this book, you are our most important critic and commentator We valueyour opinion and want to know what we’re doing right, what we could do better, whatareas you’d like to see us publish in, and any other words of wisdom you’re willing topass our way.
You can email or write me directly to let me know what you did or didn’t like about thisbook—as well as what we can do to make our books stronger
Please note that I cannot help you with technical problems related to the topic of this book, and that due to the high volume of mail I receive, I might not be able to reply to every message.
When you write, please be sure to include this book’s title and authors as well as yourname and phone or email address I will carefully review your comments and share themwith the authors and editors who worked on the book
Visit our website and register this book at www.samspublishing.com/register for
convenient access to any updates, downloads, or errata that might be available for this book
Trang 38Welcome to Red Hat Fedora 6 Unleashed! This book covers the free Linux distribution
named Fedora Core and includes a fully functional and complete operating systemproduced by the Fedora Project, sponsored by Red Hat
Fedora Core, or more simply Fedora, is directly descended from one of the most popular
Linux distributions ever: Red Hat Linux Those of you who no nothing about Linuxmight have heard of Red Hat; it is enough to know that it is the largest Linux vendor inNorth America Fedora benefits directly from many Red Hat engineers as well as the widercontributions from free software developers across the world
If you are new to Linux, you have made a great decision by choosing this book Sams
Publishing’s Unleashed books offer an in-depth look at their subject, taking in both
begin-ner and advanced users and moving them to a new level in knowledge and expertise.Fedora is a fast-changing distribution that can be updated at least twice a year Thankfully
we have tracked the development of Fedora from very early on to make sure that theinformation contained in this book mirrors closely the development of the distribution Afull copy of Fedora is included on the DVD, making it possible for you to install Linux inless than an hour!
No longer an upstart, Linux now has an enviable position in today’s modern computingworld It can be found on machines as diverse as mobile phones and wristwatches, all theway up to supercomputers—in fact, Linux currently runs on the world’s fastest computer,IBM’s Blue Gene/L Do not let the reputation of Linux put you off, though Most peoplewho have heard of Linux think that it is only found on servers, looking after websites andemails Nothing could be further from the truth because Linux is making huge inroads in
to the desktop market, too Corporations are realizing the benefits of running a stable andpowerful operating system that is easy to maintain and easy to secure Add to that thehundreds of improvements in useability, and it becomes an attractive proposition thattempts many CIOs The best bit is that as large Linux vendors improve Linux, the major-ity of those improvements make it into freely available distributions, allowing you tobenefit from the additions and refinements made You can put Fedora to work today and
be assured of a great user experience
This book provides all the information that you need to get up and running with Fedora
It even tells you how to keep Fedora running in top shape, as well as adapt Fedora tochanges in your needs and requirements Fedora can be used at home, in the workplace,
or, with permission, at your school and college In fact, you might want to poke aroundyour school’s computer rooms: You will probably find that someone has already beatenyou to the punch—Linux is commonly found in academic institutions Feel free to make
as many copies of the software as you want No copyright lawyers are going to pound onyour door because Fedora is freely distributable all over the world
After an introduction to Linux and Fedora, you will find out how to get started withFedora, including installation and initial configuration We will also take you through
Trang 39installing software, managing users, and other common administrative tasks For themore technically minded, we cover some starting steps in programming across severallanguages—why not pick one and give it a go! Through the book you will also find infor-mation on multimedia applications, digital graphics, and even gaming for after-hourswhen you are finished tinkering After you make it through the book, you will be wellequipped with the knowledge needed to use Linux successfully We do assume that youare at least familiar with an operating system already (even if it is not with Linux), andhave some basic computer knowledge.
What Is Linux?
Linux is the core, or kernel, of a free operating system first developed and released to the
world by Linus Benedict Torvalds in 1991 Torvalds, then a graduate student at theUniversity of Helsinki, Finland, is now a Fellow at the Open Source Development Lab(http://www.osdl.org/) He is an engineer and previously worked for the CPU designand fabrication company Transmeta, Inc Fortunately for all Linux users, Torvalds chose
to distribute Linux under a free software license named the GNU General Public
License (GPL)
NOTE
The free online resource Wikipedia has a great biography of Linus Torvalds that examines hislife and notable achievements It can be found at http://en.wikipedia.org/wiki/Linux_Torvalds
Or you can head on over to http://groups.google.com/group/comp.os.minix/msg/
b813d52cbc5a044b?hl=en to read a copy of Linus’s first post about Linux to the world
The GNU GPL is the brainchild of Richard M Stallman, the founder of the Free SoftwareFoundation Stallman, the famous author of the Emacs editing environment and GCCcompiler system, crafted the GPL to ensure that software that used the GPL for licensingwould always be free and available in source code form The GPL is the guiding documentfor Linux and its ownership, distribution, and copyright Torvalds holds the rights to theLinux trademark, but thanks to a combination of his generosity, the Internet, thousands
of programmers around the world, GNU software, and the GNU GPL, Linux will remainforever free and unencumbered by licensing or royalty issues See the “Licensing” sectionlater in this Introduction to learn more about the GNU GPL and other software licenses.Linux, pronounced “lih-nucks,” is free software Combining the Linux kernel with GNUsoftware tools—drivers, utilities, user interfaces, and other software such as The X.OrgFoundation’s X Window System—creates a Linux distribution There are many differentLinux distributions from different vendors, but many are derived from or closely mimicRed Hat’s distribution of Linux: Red Hat Linux
NOTE
To see just how many distributions are based on Red Hat Linux, go to http://www.linux.org/,click Distributions, and search for “Red Hat-based.” At the time of writing, 36 distributions owetheir existence to Red Hat Linux and 11 are based directly on Fedora
Trang 40What Is Fedora?
Fedora is an operating system based on the Linux kernel, created, improved, refined, anddistributed by the Fedora Project at http://fedora.redhat.com/ The Fedora Project, spon-sored by Red Hat, is an open source project supported by a worldwide community ofsoftware developers Although Fedora is not supported by Red Hat, it incorporates
improvements made to the Linux kernel and helps contribute to Red Hat’s commercialLinux distributions and software At the same time, Fedora also benefits from improve-ments made by Red Hat software engineers to Red Hat’s products Despite this symbioticrelationship, Fedora is a free operating system, built entirely from free software, and isguided by a process open to all free software developers
Roots of Red Hat and Fedora
In 1994, Marc Ewing and Bob Young combined forces to create Red Hat (named after aCornell University lacrosse team hat) to develop, release, and market an easily installed,easily managed, and easy-to-use Linux distribution Five years later, Durham, NorthCarolina–based Red Hat would have one of the most successful initial public offerings(IPOs) on the stock market In 2001, Red Hat introduced a line of products aimed at thecorporate and enterprise markets and created versions of its Red Hat Linux distributionsand associated software in a product line known as Red Hat Enterprise Linux Additionalsoftware, services, and distributions were added to the product over the next several years,such as the Advanced Server (with support for seven CPU architectures), ES (for small- tomid-range enterprise use), and WorkStation (WS) releases
Following the release of Red Hat Linux 9 in mid-2003, Red Hat announced that it wasdiscontinuing the sale of consumer-based Linux distributions Previously, the distributionshad been available in boxed sets with manuals on store shelves or in CD-ROM imageformat for free download over the Internet Red Hat then created the Fedora Project andformally opened its doors on October 22, 2003
Today, the company has grown from a handful of employees to more than 1100 in 51locations around the world
Red Hat was one of the first companies to adopt, promote, and use open source as a ness model for supporting development, technical service, support, and sales of free soft-ware to the computer industry Its business practices have spawned a shift in paradigm ofproprietary attitudes prevalent in the monopolistic software industry, and the company is
busi-a role model busi-and business lebusi-ader in the open source movement You lebusi-arn more busi-aboutRed Hat and Fedora in Chapter 1, “Introducing Fedora.”
CAUTION
The Fedora DVD included with this book is not supported by Red Hat If you want technicalsupport when using a Red Hat release, purchase a copy of Red Hat Enterprise Linux from RedHat at http://www.redhat.com/
You can also call to order In the United States, call 1-866-273-3428, extension 4555
Elsewhere in the world, check http://www.redhat.com/about/corporate/wwoffices/ for a list oflocal offices