Christopher Negus and Eric Foster-JohnsonSet up for publishing, multimedia, or gaming Enable file, printer, Web, and mail servers Prepare for Red Hat Enterprise Linux 6 Negus Foster-J
Trang 1Christopher Negus and Eric Foster-Johnson
Set up for publishing,
multimedia, or gaming
Enable file, printer,
Web, and mail servers
Prepare for Red Hat
Enterprise Linux 6
Negus Foster-Johnson
• Nearly 4GB of official Fedora software • Installable Fedora 11 desktop system Value-Packed
Official Fedora 11 install DVD Official Fedora 11 GNOME desktop live/
install CD
System Requirements: Please see the Preface and Appendix A for details and complete system requirements.
New in Fedora 11
• Ext4 file systems
• RPM 4.6
• Cortado streaming video
• Improved webcam support
• Connection sharing with NetworkManager
• Better printer support
Fedora is the best cutting-edge Linux operating system
available Install it on your own desktop or personal server
and you’ll have your hands on the latest Linux technology
Learn to use it today and you’ll be ready for upcoming
enterprise Linux systems when they arrive Install,
configure, and use Fedora as anything from a desktop to
an Internet server Use this book as a guide to installing
or running Fedora from the included DVD and Live CD.
Spin, wobble, or twist with desktop effects
Graphical administration
tools make configuration easy
Choose from hundreds of desktop and online games
Set up Fedora or Red Hat Enterprise Linux to:
• Create encrypted file systems, use lightweight desktops, and try online
games with new features in Fedora
• Navigate your computer with GNOME®, KDE®, Xfce, or Sugar
(One Laptop Per Child) Desktops
• Manage and use documents, spreadsheets, presentations, music, and images
• Connect easily to your network with NetworkManager
• Draw from massive online Fedora and third-party software repositories
• Build an Internet server with e-mail, Web, DNS, FTP, and database services
Trang 3Just because Fedora is a serious operating system doesn't mean it can't be fun too Here is a list
of ten fun and useful things to do with Fedora
1 Set Up a Personal Online Desktop: Use the GNOME Online Desktop to connect your
desktop to your friends, multimedia content, and online applications from Google, Facebook, Yahoo!, and others Click right on the desktop to immediately get you all your favorite content (See Chapter 3.)
2 Launch Fedora 11 live on your PC: Insert the live CD that comes with this book,
reboot, and start using Fedora from nearly any PC Fedora won’t touch the contents of your computer unless you tell it to If you like Fedora, select the Install button to install Fedora to your hard disk (See Chapter 3.)
3 Play Commercial Audio/Video: Licensing restrictions keep many popular codecs from
inclusion with Fedora Using third-party repositories with Fedora, you grab the codecs you need to play Windows Media (Audio, Video and MMS), MP3 audio, MPEG-2 and MPEG-4 video decoding, and others (See Chapter 8.)
4 Manage music collections: Launch Rhythmbox to gather, organize, and play music from
your hard disk, CDs, or network file systems You can even select from thousands of free songs from Magnatune and Jamendo online music services (See Chapter 8.)
5 Publish your ideas: Choose from dozens of publishing tools to create documents
(OpenOffice.org Writer), presentations (OpenOffice.org Impress) hard-copy page layouts (Scribus), and vector graphics (Inkscape) Then publish your work on paper or the Web (See Chapter 6.)
6 Share an Internet connection: Fedora can be set up as a router and a firewall With a
home or small office LAN set-up, you can use Fedora to share an Internet connection among multiple Linux, Windows, or Mac systems Then set up a firewall in Fedora to protect your LAN from intruders (See Chapters 14, 15, and 16.)
7 Play free games: As always, Fedora includes dozens of simple card games and board
games The Fedora repository includes a ton of games, including fun first-person shooter games such as Doom, strategy games such as fantasy game Wesnoth, and online battle games such as BZFlag (See Chapter 7.)
8 Run Windows applications: By adding the wine software packages, you can run many
Windows applications right from a Fedora desktop (See Chapter 5.)
9 Create an Internet server: Learn to configure a Web server (Chapter 21), FTP server
(Chapter 20) and a mail server (Chapter 19) Then use that knowledge to create a public Internet server (Chapter 25) Your server can run from your home Internet connection
10 Share over the Internet: Share your personal videos, software, or other content with
friends over the Internet, using Bittorrent swarming network transfer software While you’re at it, instant message your thoughts using Pidgin, video-conference your looks with Ekiga, and e-mail your party invitations via Evolution (See Chapter 7.)
Trang 5Fedora 11
and
Bible
Trang 7Wiley Publishing, Inc
Trang 8Fedora® 11 and Red Hat® Enterprise Linux® Bible
Copyright © 2009 by Wiley Publishing, Inc All rights reserved
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 permitted under Sections 107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA
01923, (978) 750-8400, fax (978) 750-4744 Requests to the Publisher for permission should be addressed to the Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201) 748-6011, fax (201) 748-
6008, or online at http://www.wiley.com/go/permissions
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 materials 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 contact our Customer Care Department within the U.S at (877) 762-2974, outside the U.S at (317) 572-3993 or fax (317) 572-4002
Wiley also publishes its books in a variety of electronic formats Some content that appears in print may not be available
in electronic books
Library of Congress Control Number: 2009927344
Trademarks: Wiley, the Wiley Publishing logo, and related trade dress are trademarks or registered trademarks of John
Wiley & Sons, Inc., and/or its affiliates in the United States and other countries and may not be used without written permission 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 is not associated with any product or vendor mentioned in this book
ISBN: 978-0-470-48504-0
Printed in the United States of America
10 9 8 7 6 5 4 3 2 1
Trang 9–ChristopherNegus
To Katya and Nalana
–Eric Foster-Johnson
Trang 12About the Authors
Christopher Negus has been working with UNIX systems, the Internet, and (most recently)
Linux systems for more than two decades During that time, Chris worked at AT&T Bell Laboratories, UNIX System Laboratories, and Novell, helping to develop the UNIX operating system Features from many of the UNIX projects Chris worked on at AT&T have found their way into Red Hat Enterprise Linux, Fedora, and other Linux systems
Chris is the author of all editions of what started out as Red Hat Linux Bible, which because of
the name changes of Red Hat’s Linux projects has evolved into the book you are holding
Most recently, Chris co-authored multiple books in the Linux Toolbox series: Fedora Linux Toolbox, Ubuntu Linux Toolbox, Mac OS X UNIX Toolbox, SUSE Linux Toolbox, and BSD UNIX Toolbox (Wiley Publishing) Besides that, Chris authored Linux Bible 2009 Edition and co-wrote CentOS Bible, Linux Troubleshooting Bible and Linux Toys II for Wiley Publishing Chris also authored Live Linux CDs and co-authored the Official Damn Small Linux Book, as
part of the Negus Software Solutions Series
Today, Chris works as a Linux instructor for Red Hat, Inc and has achieved certification as a Red Hat Certified Engineer (RHCE) and Red Hat Certified Examiner (RHCX) At home, Chris enjoys spending time with his wife, Sheree, and his boys, Caleb and Seth His hobbies include soccer, singing, and exercising with Sheree
Eric Foster-Johnson is a veteran programmer who works daily with Linux, Unix, and
Windows and other operating systems By day, he writes enterprise Java software for
ObjectPartners, a Minnesota consulting firm He has authored and co-authored a number of
Linux and Unix titles including Red Hat RPM Guide, Teach Yourself Linux, Teach Yourself Unix, and Perl Modules
Trang 13Mary Beth Wakefield
Vice President and
Johnna VanHoose Dinse
Media Development Project Manager
Trang 14Acknowledgments
A special acknowledgment goes to the people at Red Hat, Inc and members of the Fedora Project In particular, Paul Frields (Fedora Project leader), Max Spevack (outgoing Fedora Project leader) and Greg DeKoenigsberg (Fedora Community leader) deserve praise for their leadership in producing a consistently high-quality Linux distribution Special thanks to Pete Hnath (my new boss at Red Hat) for allowing me to complete my work on this book after hiring me to be an instructor at Red Hat
Eric Foster-Johnson continues to be a major contributor to the new content in this book I feel very fortunate to have someone as skillful as Eric as partner with me on this book that I have put so much effort into in the past decade
At Wiley, I’d like to thank Jenny Watson, Ashley Zurcher, and Laura Moss-Hollister for helping work out issues related to the publicity, media, and covers for this book Thanks to Sara Shlaer for her continued great editing and production work on this book, and for keeping
me on schedule so we could bring this book to you on time
Thanks to Daniel Scribner for shepherding the book through the final stages of production Rob Shimonski provided a thorough technical editing pass Thanks also to Margot Maley Hutchison and the others at Waterside Productions for bringing me this project
Thanks, as always, to my dear family for helping me through this project
Finally, a special thanks goes to those of you who bought this and earlier editions of Red Hat Linux Bible Go out and become a force for Linux in your work, home, and community If you
feel like expanding your Linux horizons, try some of these other books I’ve written:
• Linux Bible 2009 Edition — Contains 18 different bootable and installable Linux
distributions on DVD and CD, along with descriptions characterizing those and other
popular and interesting Linux distributions (Look for the Linux Bible 2010 Edition
coming in November 2009.)
• Fedora Linux Toolbox with François Caen — Includes 1000+ command lines to help
Fedora, RHEL, and CentOS power users get the most out of Linux To try other similar
distributions, check out Ubuntu Linux Toolbox, SUSE Linux Toolbox and BSD UNIX Toolbox by the same authors
• Linux Troubleshooting Bible with Thomas Weeks — Goes beyond this book to help
you safely deploy and troubleshoot Linux systems
• Linux Toys II — If you’re looking for something fun to do with Linux, this book
contains nine fun projects you can build with a PC and open source software
Chris Negus
Trang 16Contents
Part I: Getting Started in Fedora and RHEL
Chapter 1: An Overview of Fedora and Red Hat Enterprise Linux 3
Introducing Fedora 11 and Red Hat Enterprise Linux 4
What Is Linux? 5
Linux’s Roots in UNIX 6
What Is an Operating System? 7
Common Linux Features 8
Primary Advantages of Linux 10
What Are Red Hat Enterprise Linux and Fedora? 11
Red Hat forms the Fedora Project 11
Red Hat shifts to Red Hat Enterprise Linux 14
Choosing between Fedora and Enterprise 14
Why Choose Fedora or Red Hat Enterprise Linux? 15
Moving Toward Red Hat Enterprise Linux 6 17
New Features in Fedora 11 17
Faster Boot Times 18
PackageKit Software Management 18
Many desktop improvements 19
Firefox 3.5 Web browser 19
Ext4 file systems 19
Improved IPv6 support 19
Encrypted file systems 19
RPMfusion.org third-party software repository 19
Identity management with freeIPA 19
NetworkManager 20
Many security improvements 20
Getting custom Fedora spins 20
Creating your own spins 21
Firewall Configuration 21
The Culture of Free Software 21
Summary 22
Chapter 2: Installing Fedora 23
Understanding Fedora Installation Media 24
Using the Fedora 11 Live CD 24
Quick Installation 26
Detailed Installation Instructions 28
Installing Fedora 11 28
Choosing an installation method 29
Trang 17Choosing computer hardware 32
Installing Fedora on a Laptop 33
Preparing for installation using the live CD 33
Beginning the installation 37
Choosing Different Install Modes 39
Running Fedora Firstboot 44
Enabling Authentication 45
Going forward after installation 46
Special Installation Procedures 47
Alternatives for starting installation 47
Installing from other media 50
Starting a VNC install 52
Performing a kickstart installation 53
Special Installation Topics 59
Setting up to dual-boot Linux and Windows 59
Partitioning your disks 65
Using the GRUB boot loader 73
Troubleshooting Installation 79
Spinning Your Own Fedora Install or Live Media 81
Summary 82
Chapter 3: Getting Started with the Desktop 83
Logging in to Fedora or RHEL 84
Why Do I Need a User Login? 86
Getting Familiar with the Desktop 86
Using the GNOME Desktop 95
Using the Metacity window manager 97
Using the GNOME panels 98
Using the Nautilus file manager 104
Changing GNOME preferences 106
Managing removable media 108
Trying other GNOME applications 108
Switching to another user 110
Exiting GNOME 110
Switching Desktop Environments 111
Using the KDE Desktop 112
New Features in KDE 4.2 112
Starting with KDE 113
KDE desktop basics 114
Managing files with Dolphin and Konqueror File Managers 116
Using the Konqueror browser features 121
Configuring Konqueror and Dolphin options 122
Managing windows 124
Configuring the desktop 126
Trang 18Contents xv
Adding widgets 127
Running 3D Accelerated Desktop Effects 128
Using the Xfce Desktop Environment 131
Troubleshooting Your Desktop 132
GUI doesn’t work at start-up 132
What Happens During Desktop Startup? 133
Tuning your video card and monitor 134
Configuring video cards for gaming 136
Getting more information 136
Summary 136
Chapter 4: Using Linux Commands 139
The Shell Interface 139
Checking your login session 140
Checking directories and permissions 141
Checking system activity 143
Exiting the shell 144
Understanding the Shell 144
Using the Shell in Linux 145
Locating commands 146
Getting Help with Using the Shell 147
Rerunning commands 149
Connecting and expanding commands 154
Using shell environment variables 156
Managing background and foreground processes 160
Configuring your shell 162
Working with the Linux File System 165
Linux File Systems Versus Windows-Based File Systems 167
Creating files and directories 168
Identifying Directories 169
Moving, copying, and deleting files 173
Using the vi Text Editor 174
Starting with vi 174
Exploring Other Text Editors 175
Moving around the file 177
Searching for text 178
Using numbers with commands 178
Summary 179
Part II: Using Fedora and RHEL Chapter 5: Accessing and Running Applications 183
Getting and Installing Software Packages 184
Downloading and installing applications with yum 186
Getting Fedora and RHEL software updates 194
Trang 19Managing RPM Packages 195
Using the PackageKit Add/Remove window 196
Using the rpm command 197
Using Software in Different Formats 208
Understanding software package names and formats 208
Using Binary RPMs versus Building from Source 209
Using different archive and document formats 210
Building and installing from source code 212
Using Fedora or RHEL to Run Applications 216
Finding common desktop applications in Linux 217
Investigating your desktop 219
Starting applications from a menu 219
Starting applications from a Run Application window 220
Starting applications from a Terminal window 221
Running remote X applications 222
Running Microsoft Windows, DOS, and Macintosh Applications 227
Running DOS applications 229
Running Microsoft Windows applications in Linux 232
Running Applications in Virtual Environments 237
Running applications virtually with Xen 238
Running applications virtually with KVM and QEMU 242
Summary 244
Chapter 6: Publishing with Fedora and RHEL 245
Desktop Publishing in Linux 246
Using Text Editors and Notepads 246
Using Word Processors 246
Using Traditional Linux Publishing Tools 253
Creating Documents in Groff or LaTeX 254
Text processing with Groff 254
Text processing with TeX/LaTeX 257
Converting documents 259
Creating DocBook documents 260
Understanding SGML and XML 261
Displaying PDF Files with Adobe Acrobat Reader 264
Doing Page Layout with Scribus 266
Working with Graphics 267
Manipulating images with GIMP 268
Taking screen captures 269
Creating vector graphic images with Inkscape 270
Using Scanners Driven by SANE 272
Web Publishing 273
Summary 274
Trang 20Contents xvii
Chapter 7: Gaming in Fedora and RHEL 275
Jumping into Linux Gaming 276
Basic Linux Gaming Information 278
Where to get information on Linux gaming 278
Choosing a video card for gaming 279
Running Open Source Linux Games 281
GNOME games 281
KDE games 282
Adding more games from Fedora repository 284
Commercial Linux Games 294
Getting Started with commercial games in Linux 295
Playing commercial Linux games 295
id Software Games 296
Gaming with Cedega 298
Loki Software game demos 299
Neverwinter Nights 302
Summary 303
Chapter 8: Music, Video, and Images in Linux 305
Understanding Multimedia and Legal Issues in Linux 305
Extending Freedom to Codecs 306
Listening to Music in Linux 307
Configuring a sound card 309
Choosing audio players 316
Automatically playing CDs 317
Playing and managing music with Rhythmbox 317
Troubleshooting Your CD-ROM 318
Playing music with XMMS Audio Player 321
Using ogg123, mpg321, and play command-line players 325
Using MIDI audio players 325
Converting audio files with SoX 326
Extracting and encoding music 328
Creating your own music CDs 331
Creating CD labels with cdlabelgen 335
Viewing TV and Webcams 336
Watching TV with TVtime 337
Video conferencing and VOIP with Ekiga 339
Taking Webcam videos and snapshots with Cheese 342
Playing Video 343
Examining laws affecting video and Linux 345
Understanding video content types 346
Converting Video to Theora 347
Watching video with Xine 347
Using Totem movie player 351
Trang 21Using a Digital Camera 352
Displaying images in gThumb 353
Using your camera as a storage device 354
Summary 355
Chapter 9: Using the Internet and the Web 357
Overview of Internet Applications and Commands 357
Browsing the Web 360
Understanding Web browsing 361
Browsing the Web with Firefox 365
Setting up Firefox 369
Using text-based Web browsers 377
Communicating with E-mail 378
E-mail basics 380
Using Evolution e-mail 381
Thunderbird mail client 384
Text-based mail programs 385
Mail readers and managers 385
Participating in Newsgroups 386
Instant Messaging with Pidgin 387
Sharing Files with BitTorrent 389
Using Remote Login, Copy, and Execution 390
Getting files with FTP 390
Getting files with wget 396
Using ssh for remote login/remote execution 399
Using scp for remote file copy 400
Using the “r” commands: rlogin, rcp, and rsh 400
Summary 401
Part III: Administering Fedora and RHEL Chapter 10: Understanding System Administration 405
Using the root user account 406
Becoming Super User (The su Command) 406
Learning about Administrative GUI Tools, Commands, Configuration Files, and Log Files 408
Using graphical administration tools 408
Becoming Super User in X 409
Administrative commands 413
Administrative configuration files 413
Administrative log files 418
Using other administrative logins 418
Administering Your Linux System 421
Configuring Hardware 421
Checking your hardware 422
Managing Hardware with HAL 422
Trang 22Contents xix
Reconfiguring hardware with kudzu 423 Configuring modules 424 Managing File Systems and Disk Space 427 Mounting file systems 429 Using the mkfs command to create a file system 438 Adding a hard disk 439 Using RAID disks 441 Checking system space 444 Monitoring System Performance 446 Watch computer usage with System Monitor 447 Monitoring CPU usage with top 448 Monitoring power usage on laptop computers 448 Fixing Your System with the FirstAidKit 451 Choosing Software Alternatives 451 Selecting Java alternatives 452 Selecting mail and printing alternatives 452 Using mail alternatives 453 Using Security Enhanced Linux 453 Understanding Security Enhanced Linux 454 Types and roles in SELinux 455 Users in SELinux 455 Policies in SELinux 456 Tools in SELinux 456 Using SELinux in Fedora and RHEL 457 Getting SELinux 457 Checking whether SELinux is on 458 Checking SELinux status 459 Learning More about SELinux 460 Summary 460
Chapter 11: Setting Up and Supporting Users 463
Creating User Accounts 463 Adding users with useradd 464 Adding users with User Manager 469 Setting User Defaults 471 Supplying initial login scripts 474 Supplying initial bashrc and bash_profile files 474 Supplying an initial tcshrc file 475 Configuring system-wide shell options 476 Setting system profiles 477 Adding user accounts to servers 477 Creating Portable Desktops 478 Providing Support to Users 480 Creating a technical support mailbox 480 Resetting a user’s password 481
Trang 23Modifying Accounts 482 Modifying user accounts with usermod 482 Modifying user accounts with User Manager 484 Deleting User Accounts 485 Deleting user accounts with userdel 485 Deleting user accounts with User Manager 486 Checking Disk Quotas 487 Using quota to check disk usage 487 Using du to check disk use 491 Removing temp files automatically 492 Sending Mail to All Users 492 Summary 494
Chapter 12: Automating System Tasks 495
Understanding Shell Scripts 495 Executing and debugging shell scripts 496 Understanding shell variables 497 Performing arithmetic in shell scripts 500 Using programming constructs in shell scripts 500 Some useful external programs 506 Trying some simple shell scripts 508 System Initialization 509 Starting init 510 The inittab file 510 System Startup and Shutdown 515 Starting run-level scripts 515 Understanding run-level scripts 515 Understanding what startup scripts do 519 Changing run-level script behavior 520 Reorganizing or removing run-level scripts 521 Adding run-level scripts 523 Managing xinetd services 524 Manipulating run levels 525 Scheduling System Tasks 526 Using at.allow and at.deny 527 Specifying when jobs are run 527 Submitting scheduled jobs 528 Viewing scheduled jobs 528 Deleting scheduled jobs 529 Using the batch command 529 Using the cron facility 529 Summary 533
Trang 24Contents xxi
Chapter 13: Backing Up and Restoring Files 535
Making a Simple Backup Archive 536 Doing a Simple Backup with rsync 537 Backing up files locally 538 Backing up files remotely 539 Choosing Backup Tools 540 Selecting a Backup Strategy 541 Full backup 541 Incremental backup 541 Disk mirroring 541 Network backup 542 Selecting a Backup Medium 542 Magnetic tape 543 Writable CD drives 545 Writable DVD drives 549 Writing CD or DVDs with growisofs 551 Backing Up to a Hard Drive 551 Backing Up Files with dump 552 Creating a backup with dump 553 Understanding dump levels 555 Automating Backups with cron 556 Restoring Backed-Up Files 557 Restoring an entire file system 559 Recovering individual files 559 Configuring Amanda for Network Backups 562 Creating Amanda directories 563 Creating the amanda.conf file 563 Creating a disklist file 566 Adding Amanda network services 566 Performing an Amanda backup 567 Using the pax Archiving Tool 568 Summary 571
Chapter 14: Computer Security Issues 573
Linux Security Checklist 573 Using Password Protection 576 Choosing good passwords 577 Using a shadow password file 577 Securing Linux with the iptables Firewall 580 Using the Firewall Configuration window 580 Configuring an iptables firewall 582 Controlling Access to Services with TCP Wrappers 594 Checking Log Files 597 Understanding the rsyslogd service 597
Trang 25Tracking log messages with logwatch 601 Using the Secure Shell Package 602 Starting the SSH service 602 Using the ssh, sftp, and scp commands 603 Using ssh, scp, and sftp without passwords 604 Securing Linux Servers 606 Understanding attack techniques 606 Protecting against denial-of-service attacks 607 Protecting against distributed DOS attacks 610 Protecting against intrusion attacks 614 Securing servers with SELinux 617 Protecting Web servers with certificates and encryption 618 Exporting Encryption Technology 627 Managing Identities with FreeIPA 627 Setting up the FreeIPA Server 628 Setting up FreeIPA Clients 629 Summary 629
Part IV: Fedora and RHEL Network and Server Setup
Chapter 15: Setting Up a Local Area Network 633
Connecting to the Network with NetworkManager 633 Connecting to a wireless network 635 Connecting to a wired network 636 Setting up a virtual private network connection 637 Understanding Local Area Networks 638 Planning, getting, and setting up LAN hardware 639 Configuring TCP/IP for your LAN 643 Setting Up a Wireless LAN 650 Understanding wireless networks 651 Choosing wireless hardware 652 Getting wireless drivers 657 Installing wireless Linux software 660 Configuring the wireless LAN 661 Wireless Security 665 Testing distances 666 Setting wireless extensions 666 Understanding Internet Protocol Addresses 668
IP address classes 669 Understanding netmasks 669 Classless Inter-Domain Routing 670 Getting IP addresses 671 Troubleshooting Your LAN 672 Did Linux find your Ethernet driver at boot time? 672 Can you reach another computer on the LAN? 673
Trang 26Contents xxiii
Is your Ethernet connection up? 674 Troubleshooting a wireless LAN 676 Watching LAN traffic with Wireshark 679 Using Wireshark Filters 683 Summary 684
Chapter 16: Connecting to the Internet 685
Understanding How the Internet Is Structured 686 Internet domains 688 Hostnames and IP addresses 689 Routing 691 Proxies 691 Using Dial-Up Connections to the Internet 692 Getting information 692 Setting up dial-up PPP 693 Creating a dial-up connection with the Network Configuration window 694 Launching your PPP connection 696 Launching your PPP connection on demand 697 Checking your PPP connection 698 Connecting Your LAN to the Internet 704 Setting Up Linux as a Router 705 Configuring the Linux router 706 Configuring network clients 709 Configuring a Virtual Private Network Connection 710 Understanding IPsec 711 Using IPsec protocols 711 Using IPsec in Fedora or RHEL 712 Configuring an OpenVPN Server 713 Setting Up Linux as a Proxy Server 719 Starting the squid daemon 720 Using a simple squid.conf file 721 Modifying the Squid configuration file 724 Debugging Squid 728 Setting Up Proxy Clients 730 Configuring Firefox to use a proxy 730 Configuring other browsers to use a proxy 731 Summary 732
Chapter 17: Setting Up a Print Server 733
Common UNIX Printing Service 733 Setting Up Printers 734 Choosing a Printer 735 Using the Printer Configuration window 735 Using Web-based CUPS administration 743
Trang 27Configuring the CUPS server (cupsd.conf) 747 Configuring CUPS printer options 748 Using Printing Commands 749 Using lpr to print 749 Listing status with lpc 750 Removing print jobs with lprm 750 Configuring Print Servers 751 Configuring a shared CUPS printer 751 Configuring a shared Samba printer 752 Summary 753
Chapter 18: Setting Up a File Server 755
Goals of Setting Up a File Server 755 Setting Up an NFS File Server 756 Sharing NFS file systems 758 Using NFS file systems 765 Unmounting NFS file systems 771 Other cool things to do with NFS 772 Setting Up a Samba File Server 772 Getting and installing Samba 774 Configuring a simple Samba server 774 Configuring Samba with SWAT 778 Assigning Guest Accounts 782 Working with Samba files and commands 787 Setting up Samba clients 790 Troubleshooting your Samba server 793 Summary 796
Chapter 19: Setting Up a Mail Server 797
Introducing SMTP and sendmail 798 Installing and Running sendmail 798 Other Mail Servers for Fedora or Red Hat Linux 799 Starting sendmail 800 Other programs 800 Logging performed by sendmail 801 Configuring sendmail 802 Getting a domain name 803 Configuring basic sendmail settings (sendmail.mc) 803 Defining outgoing mail access 807 Configuring virtual servers 809 Configuring virtual users 810 Adding user accounts 811 Starting sendmail and generating database files 811 Redirecting mail 813
Trang 28Contents xxv
Introducing Postfix 815 Stopping Spam with SpamAssassin 816 Using SpamAssassin 816 Setting up SpamAssassin on your mail server 817 Setting e-mail readers to filter spam 819 Getting Mail from the Server (POP3 or IMAPv4) 820 Accessing mailboxes in Linux 820 Configuring IMAPv4 and POP3 with dovecot 821 Getting Mail from Your Browser with SquirrelMail 822 Administering a Mailing List with mailman 823 Summary 827
Chapter 20: Setting Up an FTP Server 829
Understanding FTP Servers 830 Attributes of FTP servers 830 FTP user types 831 Using the Very Secure FTP Server 831 Quick-starting vsFTPd 832 Securing vsFTPd 833 Configuring vsFTPd 833 Getting More Information about FTP Servers 839 Summary 839
Chapter 21: Setting Up a Web Server 841
Introduction to Web Servers 842 The Apache Web server 842 Other Web servers available for Fedora and RHEL 843 Quickstarting the Apache Web Server 844 Configuring the Apache Server 846 Configuring the Web server (httpd.conf) 847 Configuring modules and related services (/etc/httpd/conf.d/*.conf) 878 Starting and Stopping the Server 879 Monitoring Server Activities 881 Displaying server information 882 Displaying server status 882 Further security of server-info and server-status 883 Logging errors 884 Logging hits 884 Analyzing Web-server traffic 885 Statistics Packages Available for Fedora and RHEL 887 Summary 887
Chapter 22: Setting Up an LDAP Address Book Server 889
Understanding LDAP 890
Trang 29Defining information in schemas 891 Understanding OIDs 892 Structuring your LDAP directories 892 Setting Up the OpenLDAP Server 893 Installing OpenLDAP packages 893 Configuring the OpenLDAP server (slapd.conf) 893 Creating an Encrypted Password 896 Starting the OpenLDAP service 896 Setting Up the Address Book 896 More Ways to Configure LDAP 902 Accessing an LDAP Address Book from Thunderbird 903 Summary 905
Chapter 23: Setting Up a DHCP Boot Server 907
Using Dynamic Host Configuration Protocol 907 Setting Up a DHCP Server 908 Opening your firewall and SELinux for DHCP 909 Configuring the /etc/dhcp/dhcpd.conf file 910 Starting the DHCP server 916 Setting Up a DHCP Client 917 Summary 919
Chapter 24: Setting Up a MySQL Database Server 921
Finding MySQL Packages 922 Getting More MySQL Packages 923 Configuring the MySQL Server 924 Using mysql user/group accounts 924 Adding administrative users 924 Setting MySQL options 925 Using sample my.cnf files 930 Starting the MySQL Server 932 Checking That MySQL Server Is Working 932 Working with MySQL Databases 933 Starting the mysql command 933 Creating a database with mysql 935 Adding data to a MySQL database table 936 Understanding MySQL Tables 940 Displaying MySQL Databases 945 Displaying all or selected records 946 Displaying selected columns 947 Sorting data 947 Making Changes to Tables and Records 948 Altering the structure of MySQL tables 948 Updating and deleting MySQL records 949
Trang 30Contents xxvii
Adding and Removing User Access 950 Adding users and granting access 950 Revoking access 951 Backing Up Databases 952 Checking and Fixing Databases 952 Summary 954
Chapter 25: Making Servers Public with DNS 955
Determining Goals for Your Server 956 Using a hosting service 956 Connecting a Public Server 957 Choosing an ISP 957 Getting a domain name 960 Configuring Your Public Server 962 Configuring networking 962 Configuring servers 963 Managing security 964 Setting Up a Domain Name System Server 966 Understanding DNS 967 DNS name server example 970 Quick-starting a DNS server 972 Checking that DNS is working 980 Getting More Information about BIND 982 Summary 982
Chapter 26: Integrating Fedora with Apple Macs 983
Looking Inside Mac OS X 984 Using Network Services from Mac OS X 985 Using AppleTalk (netatalk) from Mac OS X 986 Using AppleTalk from Mac OS 8 or OS 9 988 Using Mac, Windows, and Linux servers (Samba) 988 Sharing X applications 990 Configuring an AppleTalk Server in Linux 991 Before you start using netatalk 992 Setting up the netatalk server 992 Securing netatalk volumes 998 Troubleshooting netatalk 1004 Accessing NFS Servers from the Mac 1005 Connecting to NFS from the Connect to Server window 1005 Connecting to NFS from the command line 1007 Installing Fedora on an Intel-based Mac 1008 Before installing Fedora on your Mac 1008 Installing Fedora 1009 Summary 1010
Trang 31Appendix A: About the Media 1011
Fedora Source Code 1012
Appendix B: Running Network Services 1013
Checklist for Running Networking Services 1013 Networking Service Daemons 1015 The xinetd super-server 1016 The init.d start-up scripts 1017 Choosing Alternatives 1017 Referencing Network Services 1018 Web server 1019 File servers 1019 Login servers 1020 E-mail servers 1021 News server 1022 Print servers 1022 Network administration servers 1022 Information servers 1024 Database services 1025 User services 1025 Network Services Reference 1028
Appendix C: Red Hat Enterprise Linux 5 Features 1013
What’s in RHEL 5? 1031 What’s New in RHEL 5.3? 1034 Choosing an RHEL System 1034 Getting RHEL Evaluation Subscriptions 1035 Hardware Compatibility and Commercial Software 1036 Training and Certification 1036 Documentation and Support 1037 Managing RHEL Systems 1037 Using Red Hat Network 1038 Using RHEL for high-performance computing clusters 1039 Using RHEL Global File System 1039 More Information on RHEL 1040 What’s in RHEL 5? 1031 What’s New in RHEL 5.3? 1034 Choosing an RHEL System 1034 Getting RHEL Evaluation Subscriptions 1035 Hardware Compatibility and Commercial Software 1036 Training and Certification 1036 Documentation and Support 1037 Managing RHEL Systems 1037
Trang 32Contents xxix
Using Red Hat Network 1038 Using RHEL for high-performance computing clusters 1039 Using RHEL Global File System 1039 More Information on RHEL 1040
Index 1041
Trang 34With the Fedora Linux operating system and the instructions in this book, you can transform your PC into a safe, powerful, and free computer system Starting with Fedora, you can simply replace (or coexist with) Microsoft Windows on your everyday desktop computer You can also configure your computer to share your files, printers, Web pages, or directory services to other computers Then, if you choose, you can transition your skills to manage anything from a small office to a large, corporate Red Hat Enterprise Linux computer installation
This book tells you how and gives you all the software you need to do it
Who Are You?
You don’t need to be a programmer to use this book You may be someone who just wants to use Linux (to run programs, access the Internet, and so on) Or you may simply want to know how to administer a Linux system in a workgroup or on a network
I assume that you are somewhat computer literate but have little or no experience with Linux (or UNIX) You may be migrating from Microsoft operating systems to Linux because of its networking and multiuser features You may be looking to start a career as a computer
technician or network administrator and find that spending a few dollars for an entire operating system and book is more economical than taking technical classes offered on late-night television Or you might just think a “free” operating system is cool
In any case, after you peruse this book you should have a good idea of how to run applications, set up a small network, connect to the Internet, and configure a variety of server types (Web servers, print servers, file servers, and so on) This book represents a great first few steps toward your becoming someone who can set up a home network or a small office network and maintain a group of computers
This Book’s Learn-Through-Tasks Approach
The best way to learn a computer system is to get your hands on it To help you learn Linux, this book takes a task-oriented approach Where possible, I step you through the process of working with a feature, such as setting up a network or configuring your desktop
When you are done with a task, you should have a good, basic setup of the feature that it covers After that, I often provide pointers to further information on tweaking and tuning the feature
Instead of assuming that you already know about cryptic topics such as troff, NFS, and TCP/IP, I ease you into those features with headings such as “Publishing with Fedora and RHEL,” “Setting up a File Server,” and “Connecting to the Internet.” Heck, if you already
Trang 35knew what all those things were and how to get them working, you wouldn’t need me, would you?
When many tools can be used to achieve the same results, I usually present one or two
examples In other words, I don’t describe six different Web browsers, twelve different text editors, and three different news servers I tell you how to get one or two similar tools really working and then note the others that are available
What You Need
This book covers two different Linux systems: Fedora 11 and Red Hat Enterprise Linux 5 Because Fedora is most recently released and is included on the media with this book,
examples primarily focus on Fedora However, because Fedora technology feeds into
distributions besides RHEL, such as CentOS (www.centos.org), StartCom
(www.startcom.org), White Box Enterprise Linux (www.whiteboxlinux.org) and Oracle’s Unbreakable Linux (www.oracle.com/technologies/linux), you can use this book to learn about those distributions as well
To follow along with this book, you can install the official Fedora 11 software found on the accompanying DVD If you don’t have a DVD drive, you can use the CD that comes with this book to try out Fedora and install a desktop Fedora system to your hard disk Or you can follow along with your CentOS system (which is free) or Red Hat Enterprise Linux 5 system, (which you can obtain with a subscription from Red Hat, Inc.)
To install Fedora 11 with the media that come with this book, you need a PC with the
following general configuration:
• An Intel Pentium or compatible CPU, 200MHz Pentium or better (for text mode); 400MHz Pentium II or better (for GUI mode) Fedora 11 has been optimized for
Pentium 4 processors (Intel 486 computers will not work with Fedora 11.)
• At least 64MB of RAM (text-based install) or 128MB of RAM (graphical install) To run the GNOME or KDE desktop 192MB are needed, although the Fedora Project recommends at least 512MB (For low RAM systems, try the Xfce desktop described in Chapter 2.)
• At least 620MB of hard disk space (you have to select a minimal install) You need 2.3GB of hard disk space for a personal desktop install, 3.0GB for a typical workstation installation, or at least 1.1GB of space for a server installation
• A DVD or CD drive This is recommended for installation (because we give you the installation DVD), although you can install from CD (we provide a live CD that can also
be installed to hard disk), over a network, or from a local hard disk instead For network and hard disk installs, booting installation from a 3.5-inch floppy disk drive is no longer supported Chapter 2 describes methods of launching installation if you don’t have a bootable DVD drive: Once the install is started, you need either an extra hard disk partition or another computer (that can be reached over the network) that has packages or
Trang 36Preface xxxiii
images of the Fedora distribution on it (I tell you how to do that in Chapter 2, in case
you’re interested.)
Not every piece of PC hardware works with Fedora While there is no official hardware
compatibility list as there is for Red Hat Enterprise Linux (available at http://
hardware.redhat.com), overall hardware support should be improved in Fedora 11 In
fact, wireless LAN cards, FireWire devices, and some other components have seen improved
support in recent versions of Fedora
There are versions of Fedora available for other computer architectures as well If you have a
Power PC or X86 64-bit computer, you can download official install and live CDs and DVDs
from the Fedora project (http://fedoraproject.org/en/get-fedora.html)
Likewise, you can get X86 and X86 64-bit versions of CentOS from that project’s site
(http://mirror.centos.org/)
Fedora 11 and Red Hat Enterprise Linux Bible
Improvements
Fedora® 11 and Red Hat® Enterprise Linux® Bible represents the continuing development of
Red Hat Linux Bible, which I began in 1999 About every six months since Red Hat Linux 6.1,
I followed new versions of Red Hat Linux with updates of this book
Red Hat, Inc split its Red Hat Linux development efforts into two tracks: the Fedora Project
and the Red Hat Enterprise Linux (RHEL) product This book now covers the latest of those
two Linux distributions: Fedora 11 and RHEL 5 By learning the features in Fedora 11, you
will also be preparing yourself for future releases of RHEL
The foundation for Fedora, RHEL, and this book rests on the tradition begun with Red Hat
Linux The enhancements included in this edition reflect that foundation, plus some bold new
cutting-edge Linux technology
This edition covers a wide range of features in Fedora 11 The following list describes new
features of this book over the previous edition:
• Fedora 11 Official Install DVD — We provide Fedora 11 on DVD with this edition
This is the exact DVD produced by the Fedora project, offering a wide range of desktop,
workstation, and server software
• Fedora 11 Desktop Live/Install CD — Before you install Fedora, you can try out a
desktop-oriented live version of Fedora 11 by booting the CD that comes with this book
For this edition, we decided to use the GNOME live CD (there is also a KDE live CD
available for download) While that CD is running, you can use it to prepare your
computer to do a permanent installation The contents of that CD can also be installed
directly to your hard disk
Trang 37• GNOME 2.26 Desktop — Although primarily a bug-fix release, GNOME 2.26 includes
some new features for burning CDs, file sharing, and multi-monitor support There have also been improvements to PulseAudio audio system, GNOME’s Media Player, and Epiphany Web browser
• KDE 4.2.2 Desktop — Several new applets were added to the relatively new Plasma
desktop included with KDE In particular, there is now a Network Manager Plasma applet There are also several new applets that run in the panel for features such as PowerDevil (power management) and NetworkManager (network connection manager) (KDE is not on the CD that comes with this book, but you can install it from the DVD.)
• Fast Startup — Fedora’s goal in this release is to be able to boot up and display the
login screen within 20 seconds If it hasn’t quite reached that goal, it is certainly a lot faster than it was
• Palimpset Disk Utility — Instead of just displaying disk space information (although it
does that too), the Palimpset Disk Utility can provide information about the status and
health of your storage media Type palimpset to start it The window that appears lets
you see an assessment of the disk’s health, how long it has been powered on, its current temperature, and other information
• Firefox 3.1 — This latest release of the Firefox browser features many code
enhancements to improve overall performance of the browser
• Minimal install — By only installing the packages in the core group, you can install a
Fedora system that includes only the minimal number of packages it needs to run This can be useful for appliances or as the basis for very efficient single-purpose servers
• Nouveau NVIDIA video driver — Instead of using the open source nv driver for video
cards that include NVIDIA graphics chipsets, Fedora now use the open source Nouveau driver (xf86-video-nv)
In addition to new features just described, procedures throughout the book have been tested and corrected to match changes that have occurred to Fedora 11 software in this version
Conventions Used in This Book
Throughout the book, special typography indicates code and commands Commands and code are shown in a monospaced font:
This is how code looks
In the event that an example includes both input and output, the monospaced font is still used, but input is presented in bold type to distinguish the two Here’s an example:
Trang 38Preface xxxv
NOTE: A Note box provides extra information to which you need to pay special attention
TIP: A Tip box shows a special way of performing a particular task
CAUTION: A Caution box alerts you to take special care when executing a procedure, or damage to
your computer hardware or software could result
CROSS-REFERENCE: A Cross-Reference box refers you to further information on a subject that you
can find outside the current chapter
How This Book Is Organized
The book is organized into four parts
Part I: Getting Started in Fedora and RHEL
Part I consists of Chapters 1 through 4 Chapters 1 and 2 contain brief descriptions of the
Linux technology and tell you what you need to get the operating system installed Chapter 1
serves as an introduction to the Linux operating system and to Fedora in particular I also pay
special attention to the division Red Hat, Inc., makes between the Fedora Project and Red Hat
Enterprise Linux Chapter 2 discusses what you need to install Fedora and how to make the
decisions you’ll be faced with during installation It includes procedures for installing from
DVD, CD-ROM, hard disk, or network connection (NFS, FTP, or HTTP servers)
In Chapter 3, you learn about the GNOME, KDE, and Xfce desktop environments, as well as
the X Window system These GUIs provide graphical means of using Fedora and RHEL
Chapter 4 describes ways of exploring and understanding Fedora and RHEL, primarily from
the Linux shell command interpreter You learn how to use the bash shell, the vi text editor,
and the commands for moving around the Linux file system
Part II: Using Fedora and RHEL
Part II consists of Chapters 5 through 9, which include information for the average user who
wants to use Linux to run applications and access the Internet
Chapter 5 contains information on obtaining, installing, and running Linux applications It also
helps you run applications from other operating systems in Linux Chapter 6 describes both
old-time publishing tools and new, graphical word processors that are available with Fedora
and RHEL Old tools include the troff and TeX text processing tools, whereas newer
publishing software includes OpenOffice.org utilities (included on the DVD) and StarOffice
(commercially available)
Trang 39GNOME and KDE games that run in Fedora and RHEL are described in Chapter 7 This chapter also describes how to run commercial Windows games using Cedega, and commercial Linux games, such as Civilization: Call to Power and Myth II, some of which have demo versions available Chapter 8 describes how to use audio and video players, as well as how to configure sound cards and CD burners Chapter 9 describes tools for browsing the Web (such
as the Firefox browser) and related tools (such as e-mail clients and newsreaders)
Part III: Administering Fedora and RHEL
Part III consists of Chapters 10 through 14, which cover general setup and system maintenance tasks, including how to set up user accounts, automate system tasks, and back up your data Chapter 10, in which you learn what you need to know about basic system administration, describes the root login, administrative commands, configuration files, SELinux, and log files Chapter 11 describes how to set up and provide support for multiple users on your Fedora or RHEL system
In Chapter 12 you learn to create shell scripts and to use the cron facility to automate a variety
of tasks on your Fedora and RHEL system Techniques for backing up your system and restoring files from backup are described in Chapter 13 Chapter 14 describes issues related to securing your computing assets in Fedora and RHEL
Part IV: Fedora and RHEL Network and Server Setup
Part IV consists of Chapters 15 through 26, which describe step-by-step procedures for setting
up a variety of server types Simple configurations for what might otherwise be complex tasks are contained in each chapter Learn to arrange, address, and connect your Linux computers to
a local area network (LAN) in Chapter 15 Chapter 16 describes techniques for connecting your Linux computer and LAN to the Internet, using features such as Point-to-Point Protocol (PPP), IP forwarding, IP masquerading, routing, and proxy servers
Chapter 17 describes how to set up different types of print server interfaces, including Samba (to share with Windows systems) and native Linux CUPS printing Chapter 18 describes file servers, such as Network File System (NFS) servers and Samba file servers Chapter 19 describes how to configure sendmail or postfix e-mail servers
Chapter 20 describes how to configure and secure an FTP server, as well as how to access the server using FTP client programs Chapter 21 teaches you how to set up Fedora or RHEL as a Web server, focusing on the popular Apache server software Chapter 22 explains how to use LDAP to create a shared address book Chapter 23 describes how to set up a DHCP server to distribute information to client workstations on the network
Chapter 24 describes how to set up and use a MySQL database server in Linux Chapter 25 takes you through the process of making the servers you configured in the other chapters available on the Internet Setting up a Domain Name System (DNS) server is also described in Chapter 25 Chapter 26 describes how to set up Fedora or RHEL to be a Macintosh file and
Trang 40Preface xxxvii
printer server It also describes how to install Fedora on a new Intel-based Mac, so you can
dual boot between Mac OS X and Fedora
Appendixes
This book contains three appendixes Appendix A describes the contents of the companion
media Appendix B provides an overview of setting up and running network services
Appendix C covers features in Red Hat Enterprise Linux 5
About the Companion Media
The Fedora 11 DVD that accompanies this book provides the software you need for a
complete working Fedora system With this software, you can install sets of software packages
that result in an installation from a few hundred megabytes to up to well over 7 gigabytes of
software
We also include a Fedora 11 GNOME Desktop Live/Install CD That CD can be booted to run
a live Fedora GNOME desktop system, without touching the contents of your hard disk You
can install the contents of the live CD to your hard disk, to use that desktop system
permanently from your hard disk
This book describes how to configure and use the software for those different media See
Appendix A for specifics on the media
Like the binary software packages, the source code packages are available from the Fedora
Project site (http://fedoraproject.org/get-fedora.html)
Reach Out
If you have any questions or comments about this book, feel free to contact me by e-mail at
chris@linuxtoys.net I get busy sometimes, but I'll do my best to help