Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
The book
Whether you are an end user, a system administrator, or a little of both, this book explains with step-by-step examples how to get the most out of a Fedora or Red Hat Enterprise Linux (RHEL) system. In 28 chapters, this book takes you from installing a Fedora or RHEL system through understanding its inner workings to setting up secure servers that run on the system.
The audience
This book is designed for a wide range of readers. It does not require you to have programming experience, although having some experience using a general-purpose computer, such as a Windows, Macintosh, UNIX, or other Linux system, is certainly helpful. This book is appropriate for
Students who are taking a class in which they use Linux
Home users who want to set up and/or run Linux
Professionals who use Linux at work
System administrators who need an understanding of Linux and the tools that are available to them including the bash and Perl scripting languages
Computer science students who are studying the Linux operating system
Technical executives who want to get a grounding in Linux
Benefits
A Practical Guide to Fedora™ and Red Hat® Enterprise Linux®, Fifth Edition, gives you a broad understanding of many facets of Linux, from installing Fedora/RHEL through using and customizing it. No matter what your background, this book delivers the knowledge you need to get on with your work. You will come away from this book understanding how to use Linux, and this book will remain a valuable reference for years to come.
New in this edition
This edition includes many updates to the previous edition:
An all-new chapter on the Perl programming language (Chapter 28; page 975)
Coverage of the MySQL relational database, which has been added to Chapter 16 (page 584)
Coverage of the Cacti network monitoring tool, which has been added to Chapter 17 (page 607)
Updated chapters to reflect the Fedora 12 and Red Hat Enterprise Linux 5.4 releases
Overlap
If you read A Practical Guide to Linux® Commands, Editors, and Shell Programming, Second Edition, you will notice some overlap between that book and the one you are reading now. The first chapter; the chapters on the utilities, the filesystem, and Perl; and the appendix on regular expressions are very similar in the two books, as are the three chapters on the Bourne Again Shell (bash). Chapters that appear in this book but not in A Practical Guide to Linux® Commands, Editors, and Shell Programming, Second Edition, include Chapters 2 and 3 (installation), Chapters 4 and 8 (Fedora/RHEL and the GUI), Chapter 10 (networking), all of the chapters in Part IV (system administration) and Part V (servers), and Appendix C (security).
Differences
While this book explains how to use Linux from a graphical interface and from the command line (a textual interface), A Practical Guide to Linux® Commands, Editors, and Shell Programming, Second Edition, works exclusively with the Linux and Mac OS X command line. It includes full chapters on the vi and emacs editors, as well as chapters on the gawk pattern processing language and the sed stream editor. In addition, it has a command reference section that provides extensive examples of the use of 100 of the most important Linux and Mac OS X utilities. You can use these utilities to solve problems without resorting to programming in C.
A Practical Guide to Fedora™ and Red Hat® Enterprise Linux®, Fifth Edition, includes a DVD that you can use to install or upgrade to Fedora 12. Chapter 2 helps you get ready to install Fedora. Chapter 3 provides step-by-step instructions for installing Fedora from this DVD. This book guides you through learning about, using, and administrating Fedora or RHEL.
The fifth edition of A Practical Guide to Fedora™ and Red Hat® Enterprise Linux® covers Fedora 12 and Red Hat Enterprise Linux version 5.4. Chapters 2 and 3 describe the process of booting into a live session and installing from live media. There is a new section on MySQL in Chapter 16 and new coverage of Cacti in Chapter 17. All of the changes—both large and small—that have been made to Fedora/RHEL since the previous edition of this book was published have been incorporated into the explanations and examples.
This book is designed and organized so you can get the most out of it in the least amount of time. You do not have to read this book straight through in page order. Instead, once you are comfortable using Linux, you can use this book as a reference: Look up a topic of interest in the table of contents or index and read about it. Or think of the book as a catalog of Linux topics: Flip through the pages until a topic catches your eye. The book includes many pointers to Web sites where you can obtain additional information: Consider the Internet to be an extension of this book.
A Practical Guide to Fedora™ and Red Hat® Enterprise Linux®, Fifth Edition, is structured with the following features:
In this book, the term “Fedora/RHEL” refers to both Fedora and Red Hat Enterprise Linux. Features that apply to only one operating system or the other are marked as such using these indicators: FEDORA or RHEL.
Optional sections enable you to read the book at different levels, returning to more difficult material when you are ready to delve into it.
Caution boxes highlight procedures that can easily go wrong, giving you guidance before you run into trouble.
Tip boxes highlight ways that you can save time by doing something differently or situations when it may be useful or just interesting to have additional information.
Security boxes point out places where you can make a system more secure. The security appendix presents a quick background in system security issues.
Concepts are illustrated by practical examples throughout the book.
Chapter summaries review the important points covered in each chapter.
Review exercises are included at the end of each chapter for readers who want to further hone their skills. Answers to even-numbered exercises can be found at www.sobell.com.
This book provides resources for finding software on the Internet. It also explains how to download and install software using yum, BitTorrent, and, for Red Hat Enterprise Linux, Red Hat Network (RHN).
The glossary defines more than 500 common terms.
The chapters that cover servers include JumpStart sections that get you off to a quick start using clients and setting up servers. Once a server is up and running, you can test and modify its configuration as explained in the rest of each of these chapters.
This book describes in detail many important GNU tools, including the GNOME desktop, the Nautilus File Browser, the parted and palimpsest partition editors, the gzip compression utility, and many command-line utilities that come from the GNU project.
Pointers throughout the text provide help in obtaining online documentation from many sources, including the local system, the Red Hat Web site, the Fedora Project Web site, and other locations on the Internet.
Many useful URLs (Internet addresses) point to sites where you can obtain software, security programs and information, and more.
The comprehensive index helps you locate topics quickly and easily.
This book contains a lot of information. This section distills and summarizes its contents. In addition, “Details” (starting on page xliii) describes what each chapter covers. Finally, the table of contents provides more detail. This book:
Installation
Describes how to download Fedora ISO image files from the Internet and burn both Fedora Desktop Live Media CD/DVDs and Fedora Install Media CD/DVDs.
Helps you plan the layout of the system’s hard disk and assists you in using Disk Druid or the GNOME palimpsest disk utility to partition the hard disk.
Explains how to set up a dual-boot system so you can install Fedora or RHEL on a Windows system and boot either operating system.
Explains how to use the Logical Volume Manager (LVM2) to set up, grow, and migrate logical volumes, which are similar in function to traditional disk partitions.
Discusses booting into a live Fedora session and installing Fedora from that session.
Describes in detail how to install Fedora/RHEL from a DVD, CD, a hard disk, or over a network using FTP, NFS, or HTTP.
Covers boot command-line parameters (FEDORA), responses to the boot: prompt (RHEL), and working with Anaconda, Fedora/RHEL’s installation program.
Working with Fedora/RHEL
Introduces the GNOME desktop (GUI) and explains how to use desktop tools, including the Top and Bottom panels, panel objects, the Main menu, object context menus, the Workspace Switcher, the Nautilus File Browser, and the GNOME terminal emulator.
Explains how to use the Appearance Preferences window to add and modify themes to customize your desktop to please your senses and help you work more efficiently.
Details how to set up 3D desktop visual effects that take advantage of Compiz Fusion.
Covers the Bourne Again Shell (bash) in three chapters, including an entire chapter on shell programming that includes many sample shell scripts. These chapters provide clear explanations and extensive examples of how bash works both from the command line in day-to-day work and as a programming language in which to write shell scripts.
Explains the textual (command-line) interface and introduces more than 30 command-line utilities.
Presents a tutorial on the vim textual editor.
Covers types of networks, network protocols, and network utilities.
Explains hostnames, IP addresses, and subnets, and explores how to use host and dig to look up domain names and IP addresses on the Internet.
Covers distributed computing and the client/server model.
Explains how to use ACLs (access control lists) to fine-tune user access permissions.
System administration
Explains how to use the Fedora/RHEL graphical and textual (command-line) tools to configure the display, DNS, NFS, Samba, Apache, a firewall, a network interface, and more. You can also use these tools to add users and manage local and remote printers.
Describes how to use the following tools to download software and keep a system current:
yum—Downloads and installs software packages from the Internet, keeping a system up-to-date and resolving dependencies as it processes the packages. You can run yum manually or set it up to run automatically every night.
BitTorrent—Good for distributing large amounts of data such as the Fedora installation DVD and the live media CD/DVD. The more people who use BitTorrent to download a file, the faster it works.
up2date—The Red Hat Enterprise Linux tool for keeping system software current.
Covers graphical system administration tools, including the many tools available from the GNOME Main menu.
Explains system operation, including the boot process, init scripts, rescue mode, single-user and multiuser modes, and steps to take if the system crashes.
Describes how to use and program the new Upstart init daemon, which replaces the System V init daemon.
Describes files, directories, and filesystems, including types of files and filesystems, fstab (the filesystem table), automatically mounted filesystems, filesystem integrity checks, filesystem utilities, and fine-tuning of filesystems.
Explains how to set up and use the Cacti network monitoring tool to graph system and network information over time.
Covers backup utilities, including tar, cpio, dump, and restore.
Explains how to customize and build a Linux kernel.
Security
Helps you manage basic system security issues using ssh (secure shell), vsftpd (secure FTP server), Apache (the httpd Web server), iptables (firewall), and more.
Presents a complete section on SELinux (Security Enhanced Linux), including instructions for using system-config-selinux to configure SELinux.
Covers the use of system-config-firewall to set up a basic firewall to protect the system.
Provides instructions on using iptables to share an Internet connection over a LAN and to build advanced firewalls.
Describes how to set up a chroot jail to protect a server system.
Explains how to use TCP wrappers to control who can access a server.
Covers controlling servers using the xinetd superserver.
Clients and servers
Explains how to set up and use the most popular Linux servers, providing a chapter on each: Apache, Samba, OpenSSH, sendmail, DNS, NFS, FTP, NIS and LDAP, and iptables (all of which are included with Fedora/RHEL).
Describes how to set up a CUPS printer server.
Explains how to set up and use a MySQL relational database.
Describes how to set up and use a DHCP server.
Programming
Provides an all-new chapter on the Perl programming language and a full chapter covering shell programming using bash, including many examples.
Chapter 1 presents a brief history of Linux and explains some of the features that make it a cutting-edge operating system. The “Conventions Used in This Book” (page 16) section details the typefaces and terminology used in this book.
Part I, “Installing Fedora and Red Hat Enterprise Linux,” discusses how to install both Fedora and RHEL. Chapter 2 presents an overview of the process of installing Fedora and RHEL, including hardware requirements, downloading and burning a CD or DVD, and planning the layout of the hard disk. Chapter 3 is a step-by-step guide to installing either Fedora or Red Hat Enterprise Linux; it covers installing from a CD/DVD, in a live session, from a local hard disk, and over the network using FTP, NFS, or HTTP. It also shows how to customize your graphical desktop (GUI).
Part II, “Getting Started with Fedora and Red Hat Enterprise Linux,” familiarizes you with Fedora/RHEL, covering logging in, the GUI, utilities, the filesystem, and the shell. Chapter 4 introduces desktop features, including the Top and Bottom panels and the Main menu; explains how to use the Nautilus File Browser to manage files, run programs, and connect to FTP and HTTP servers; covers finding documentation, dealing with login problems, and using the window manager; and presents some suggestions on where to find documentation, including manuals, tutorials, software notes, and HOWTOs. Chapter 5 introduces the shell command-line interface, describes more than 30 useful utilities, and presents a tutorial on the vim text editor. Chapter 6 discusses the Linux hierarchical filesystem, covering files, filenames, pathnames, working with directories, access permissions, and hard and symbolic links. Chapter 7 introduces the Bourne Again Shell (bash) and discusses command-line arguments and options, redirecting input to and output from commands, running programs in the background, and using the shell to generate and expand filenames.
Tip: Experienced users may want to skim Part II
If you have used a UNIX or Linux system before, you may want to skim or skip some or all of the chapters in Part II. Two sections that all readers should take a look at “Conventions Used in This Book” (page 16), which explains the typographic and layout conventions used in this book, and “Where to Find Documentation” (page 124), which points out both local and remote sources of Linux/Fedora/RHEL documentation.
Part III, “Digging into Fedora and Red Hat Enterprise Linux,” goes into more detail about working with the system. Chapter 8 discusses the GUI (desktop) and includes a section on how to run a graphical program on a remote system and have the display appear locally. The section on GNOME describes several GNOME utilities and goes into more depth about the Nautilus File Browser. Chapter 9 extends the bash coverage from Chapter 7, explaining how to redirect error output, avoid overwriting files, and work with job control, processes, startup files, important shell builtin commands, parameters, shell variables, and aliases. Chapter 10 explains networks, network security, and the Internet and discusses types of networks, subnets, protocols, addresses, hostnames, and various network utilities. The section on distributed computing describes the client/server model and some of the servers you can use on a network. Details of setting up and using clients and servers are reserved until Part V.
Part IV covers system administration. Chapter 11 discusses core concepts such as working with root privileges (working as Superuser), SELinux (Security Enhanced Linux), system operation, general information about how to set up a server, DHCP, and PAM. Chapter 12 explains the Linux filesystem, going into detail about types of files, including special and device files, the use of fsck to verify the integrity of and repair filesystems, and the use of tune2fs to change filesystem parameters. Chapter 13 explains how to keep a system up-to-date by downloading software from the Internet and installing it, including examples that use yum, BitTorrent, and RHEL’s up2date utility. Chapter 14 explains how to set up the CUPS printing system so you can print on the local system as well as on remote systems. Chapter 15 details customizing and building a Linux kernel. Chapter 16 covers additional administration tasks, including setting up user accounts, backing up files, scheduling automated tasks, tracking disk usage, solving general problems, and installing and running MySQL. Chapter 17 explains how to set up a local area network (LAN), including both hardware (including wireless) and software setup. It also discusses using Cacti to monitor a network.
Part V goes into detail about setting up and running servers and connecting to them with clients. The chapters in this part of the book cover the following clients/servers:
OpenSSH— Set up an OpenSSH server and use sh, scp, and sftp to communicate securely over the Internet.
FTP— Set up a vsftpd secure FTP server and use any of several FTP clients to exchange files with the server.
Mail— Configure sendmail and use Webmail, POP3, or IMAP to retrieve email; use SpamAssassin to combat spam.
NIS and LDAP— Set up NIS to facilitate system administration of a LAN and LDAP to distribute information and authenticate users over a network.
NFS— Share filesystems between systems on a network.
Samba— Share filesystems and printers between Windows and Linux systems.
DNS/BIND— Set up a domain nameserver to let other systems on the Internet know the names and IP addresses of local systems they may need to contact.
iptables— Share a single Internet connection between systems on a LAN and set up a firewall to protect local systems.
Apache— Set up an HTTP server that serves Web pages, which browsers can then display.
Part VI covers two important programming tools that are used extensively in Fedora/RHEL system administration and general-purpose programming. Chapter 27 continues where Chapter 9 left off, going into greater depth about shell programming using bash, with the discussion enhanced by extensive examples. Chapter 28 introduces the popular, feature-rich Perl programming language, including coverage of regular expressions and file handling.
Part VII includes appendixes on regular expressions, helpful Web sites, system security, and free software. This part also includes an extensive glossary with more than 500 entries and a comprehensive index.
The author’s home page (www.sobell.com) contains downloadable listings of the longer programs from this book as well as pointers to many interesting and useful Linux sites on the World Wide Web, a list of corrections to the book, answers to even-numbered exercises, and a solicitation for corrections, comments, and suggestions.
First and foremost, I want to thank Mark L. Taub, Editor-in-Chief, Prentice Hall, who provided encouragement and support through the hard parts of this project. Mark is unique in my 26 years of book writing experience: an editor who works with the tools I write about. Because Mark runs Linux on his home computer, we shared experiences as I wrote this book. Mark, your comments and direction are invaluable; this book would not exist without your help. Thank you, Mark T.
Molly Sharp of ContentWorks worked with me day-by-day during production of this book providing help, listening to my rants, and keeping everything on track. Thanks to Jill Hobbs, Copyeditor, who made the book readable, understandable, and consistent; and Bob Campbell, Proofreader, who made each page sparkle and found the mistakes that the author left behind.
Thanks also to the folks at Prentice Hall who helped bring this book to life, especially Julie Nahil, Full-Service Production Manager, who oversaw production of the book; John Fuller, Managing Editor, who kept the large view in check; Brandon Prebynski, Marketing Manager; Kim Boedigheimer, Editorial Assistant, who attended to the many details involved in publishing this book; Heather Fox, Publicist; Dan Scherf, Media Developer; Cheryl Lenser, Senior Indexer; Sandra Schroeder, Design Manager; Chuti Prasertsith, Cover Designer; and everyone else who worked behind the scenes to make this book come into being.
Susan Lauber, Lauber System Solutions, Inc., had a big impact on this book. She reviewed drafts of many chapters, providing insights, tips, and corrections throughout. I was very impressed with the depth and breadth of her knowledge of Fedora/RHEL systems.
A big “thank you” to the other folks who read through the drafts of the book and made comments that caused me to refocus parts of the book where things were not clear or were left out altogether: George Vish II, Senior Education Consultant, Hewlett-Packard; John Poelstra, Fedora Program Manager, Red Hat, Inc.; Max Sobell, New York University; Joe Barker, Ubuntu Forums Staff Member; Matthew Leingang, Clinical Associate Professor of Mathematics, New York University; and Kimberlee Jensen Stedl, Software Consultant and Web Developer.
I am also indebted to Denis Howe, Editor of The Free On-line Dictionary of Computing (FOLDOC). Denis has graciously permitted me to use entries from his compilation. Be sure to look at this dictionary (www.foldoc.org).
Thanks also to the following people who helped with the earlier editions of my books: John Dong, Ubuntu Developer, Forums Council Member; Andy Lester, author of Land the Tech Job You Love: Why Skill and Luck Are Not Enough, who helped extensively with the Perl chapter; Mike Basinger, Ubuntu Community and Forums Council Member; Matthew Miller, Senior Systems Analyst/Administrator, BU Linux Project, Boston University Office of Information Technology; James Stockford, Systemateka, Inc.; Stephanie Troeth, Book Oven; Doug Sheppard; Bryan Helvey, IT Director, OpenGeoSolutions; Vann Scott, Baker College of Flint; Jesse Keating, Fedora Project; Jarod Wilson, Sr. Software Engineer, Red Hat, Inc.; Scott Mann, Aztek Networks; David Chisnall; Chris Karr, Northwestern University; Carsten Pfeiffer, Software Engineer and KDE Developer; Aaron Weber, Ximian; Cristof Falk, Software Developer at CritterDesign; Steve Elgersma, Computer Science Department, Princeton University; Scott Dier, University of Minnesota; Robert Haskins, Computer Net Works; Lars Kellogg-Stedman, Harvard University; Jim A. Lola, Principal Systems Consultant, Privateer Systems, LLC; Eric S. Raymond, cofounder, Open Source Initiative; Scott Mann; Randall Lechlitner, Independent Computer Consultant; Jason Wertz, Computer Science Instructor, Montgomery County Community College; Justin Howell, Solano Community College; Ed Sawicki, The Accelerated Learning Center; David Mercer, Contechst; Jeffrey Bianchine, Advocate, Author, Journalist; John Kennedy; and Jim Dennis, Starshine Technical Services.
Thanks also to Dustin Puryear, Puryear Information Technology; Gabor Liptak, Independent Consultant; Bart Schaefer, Chief Technical Officer, iPost; Michael J. Jordan, Web Developer, Linux Online Inc.; Steven Gibson, owner of SuperAnt.com; John Viega, founder and Chief Scientist, Secure Software, Inc.; K. Rachael Treu, Internet Security Analyst, Global Crossing; Kara Pritchard, K & S Pritchard Enterprises, Inc.; Glen Wiley, Capital One Finances; Karel Baloun, Senior Software Engineer, Looksmart, Ltd.; Matthew Whitworth; Dameon D. Welch-Abernathy, Nokia Systems; Josh Simon, Consultant; Stan Isaacs; and Dr. Eric H. Herrin II, Vice President, Herrin Software Development, Inc. And thanks to Doug Hughes, long-time system designer and administrator, who gave me a big hand with the sections on system administration, networks, the Internet, and programming.
More thanks go to consultants Lorraine Callahan and Steve Wampler; Ronald Hiller, Graburn Technology, Inc.; Charles A. Plater, Wayne State University; Bob Palowoda; Tom Bialaski, Sun Microsystems; Roger Hartmuller, TIS Labs at Network Associates; Kaowen Liu; Andy Spitzer; Rik Schneider; Jesse St. Laurent; Steve Bellenot; Ray W. Hiltbrand; Jennifer Witham; Gert-Jan Hagenaars; and Casper Dik.
A Practical Guide to Fedora™ and Red Hat® Enterprise Linux®, Fifth Edition, is based in part on two of my previous UNIX books: UNIX System V: A Practical Guide and A Practical Guide to the UNIX System. Many people helped me with those books, and thanks here go to Pat Parseghian, Dr. Kathleen Hemenway, and Brian LaRose; Byron A. Jeff, Clark Atlanta University; Charles Stross; Jeff Gitlin, Lucent Technologies; Kurt Hockenbury; Maury Bach, Intel Israel Ltd.; Peter H. Salus; Rahul Dave, University of Pennsylvania; Sean Walton, Intelligent Algorithmic Solutions; Tim Segall, Computer Sciences Corporation; Behrouz Forouzan, DeAnza College; Mike Keenan, Virginia Polytechnic Institute and State University; Mike Johnson, Oregon State University; Jandelyn Plane, University of Maryland; Arnold Robbins and Sathis Menon, Georgia Institute of Technology; Cliff Shaffer, Virginia Polytechnic Institute and State University; and Steven Stepanek, California State University, Northridge, for reviewing the book.
I continue to be grateful to the many people who helped with the early editions of my UNIX books. Special thanks are due to Roger Sippl, Laura King, and Roy Harrington for introducing me to the UNIX system. My mother, Dr. Helen Sobell, provided invaluable comments on the original manuscript at several junctures. Also, thanks go to Isaac Rabinovitch, Professor Raphael Finkel, Professor Randolph Bentson, Bob Greenberg, Professor Udo Pooch, Judy Ross, Dr. Robert Veroff, Dr. Mike Denny, Joe DiMartino, Dr. John Mashey, Diane Schulz, Robert Jung, Charles Whitaker, Don Cragun, Brian Dougherty, Dr. Robert Fish, Guy Harris, Ping Liao, Gary Lindgren, Dr. Jarrett Rosenberg, Dr. Peter Smith, Bill Weber, Mike Bianchi, Scooter Morris, Clarke Echols, Oliver Grillmeyer, Dr. David Korn, Dr. Scott Weikart, and Dr. Richard Curtis.
I take responsibility for any errors and omissions in this book. If you find one or just have a comment, let me know (mgs@sobell.com) and I will fix it in the next printing. My home page (www.sobell.com) contains a list of errors and credits those who found them. It also offers copies of the longer scripts from the book and pointers to many interesting Linux pages.
Mark G. Sobell
San Francisco, California