A practical guide to Fedora and Red Hat Enterprise Linux, 7th Edition (2014)


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 RHEL (Red Hat Enterprise Linux) system. In 29 chapters, this book takes you from installing a Fedora/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 another 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 Python scripting languages

• Computer science students who are studying the Linux operating system

• Technical executives who want to get a grounding in Linux


A Practical Guide to Fedora and Red Hat® Enterprise Linux®, Seventh 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 provides 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.

Features in this edition

This edition covers many topics to help you get your work done using Fedora/RHEL.

• Full coverage of LPI’s Linux Essentials certification learning goals and extensive coverage of CompTIA’s Linux+ exam objectives (Appendix E; page 1189)

• Updated chapters reflecting new features in Fedora 19 and RHEL 7 (beta)

• A new chapter that covers setting up VMs (virtual machines) and working in the cloud (Chapter 17; page 659)

• A new chapter on the Python programming language (Chapter 28; page 1081)

• A new chapter covering 32 Linux utilities (Chapter 7; page 215)

• A new chapter on the MariaDB/MySQL relational database (Chapter 29; page 1113)

• New coverage of the firewalld service (Chapter 25; page 898)

• Tutorials on the vim and nano editors (Chapter 7; pages 262 and 270)

• Nine chapters on system administration (Part III; page 325)

• A chapter on writing programs using bash (Chapter 27; page 981)

• Coverage of the XFS filesystem (Chapter 11; page 527)

• Coverage of LDAP (Chapter 21; page 786)

• A section on the Cacti network monitoring tool (Chapter 16; page 645)

• Coverage of IPv6 (Chapter 8; page 293)

• Four indexes, making it easier to quickly find what you are looking for. These indexes locate tables (page numbers followed by the letter t), provide definitions (italic page numbers), and differentiate between light and comprehensive coverage (light and standard fonts).

Image The JumpStart index (page 1283) lists all JumpStart sections in this book. These sections help you set up servers and clients as quickly as possible.

Image The File Tree index (page 1285) lists, in hierarchical fashion, most files mentioned in this book. These files are also listed in the Main index.

Image The Utility index (page 1289) supplies the location of all utilities mentioned in this book. A page number in a light font indicates a brief mention of the utility, whereas the regular font indicates more substantial coverage. The Utility index also appears on the inside of the front and back covers of the print book.

Image The revised Main index (page 1295) is designed for ease of use.


If you have read A Practical Guide to Linux® Commands, Editors, and Shell Programming, Third Edition, you will notice some overlap between that book and the one you are reading now. The first chapter, the chapters on the utilities and the filesystem, the appendix on regular expressions, and the Glossary are very similar in the two books, as are the three chapters on the Bourne Again Shell (bash) and the chapters on Python and MariaDB. Chapters that appear in this book but do not appear in A Practical Guide to Linux® Commands, Editors, and Shell Programming, Third Edition, include Chapters 2 and 3 (installation), Chapter 4 (Fedora/RHEL and the GUI), Chapter 8 (networking), all of the chapters in Part III (system administration) and Part IV (servers), and Appendix C (security).


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, Third Edition, works exclusively with the command line and covers Mac OS X in addition to Linux. It includes full chapters on the vim and emacs editors, as well as chapters on the gawk pattern processing language, the sed stream editor, and the rsync secure copy utility. In addition, it has a command reference section that provides extensive examples of the use of 98 of the most important Linux and Mac OS X utilities. You can use these utilities to solve problems without resorting to programming in C.

This Book Includes a Fedora 19 (Schrödinger’s Cat) DVD

The print book includes a DVD that holds an Install Image of Fedora 19 (Schrödinger's Cat). You can use this DVD to install Fedora 19. Chapter 2 helps you get ready to install Fedora/RHEL. Chapter 3 provides step-by-step instructions for installing Fedora from this DVD as well as installing RHEL. This book guides you through learning about, using, and administrating a Fedora/RHEL system.

DVD features

The DVD includes many of the software packages supported by Fedora. You can use it to perform a graphical or textual (command-line) installation of either a graphical or a textual Fedora system. If you do not have an Internet connection, you can use the DVD as a software repository: After you have installed Fedora, you can install supported software packages from the DVD.

For Readers of Digital Editions

If you are reading a digital edition of this book, see “Downloading an Installation Image File and Writing to/Burning the Installation Medium” on page 46 for instructions on how to download an Install Image and create a DVD or USB flash drive that holds an that image.

Features of This Book

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 in an 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®, Seventh 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 of these operating systems are marked as such.

• 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 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 and includes a tutorial on GPG.

• Concepts are illustrated by practical examples throughout the book.

• Each chapter starts with a list of chapter objectives—a list of important tasks you should be able to perform after reading the chapter.

• 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 are posted at www.sobell.com.

• The Glossary defines more than 500 commonly encountered terms.

• The chapters covering 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 is explained in the rest of each of these chapters.

• This book provides resources for finding software on the Internet. It also explains how to download and install software using yum, the Software window, and BitTorrent. It details controlling automatic updates using the Software Update Preferences window.

• This book describes in detail many important GNU tools, including the GNOME 3 desktop, the Nautilus File Browser, the parted and gnome-disks 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 Fedora/RHEL Web sites, and other locations on the Internet.

• Multiple comprehensive indexes help you locate topics quickly and easily.

Key Topics Covered in This Book

This section distills and summarizes the information covered by this book. In addition, “Details” (starting on page l) describes what each chapter covers. Finally, the Table of Contents (starting on page xvii) provides more detail. This book:


• Describes how to download Fedora installation images from the Internet and write/burn the Fedora Live or Install Image to a USB flash drive or DVD.

• Helps you plan the layout of the system’s hard disk. It includes a discussion of partitions, partition tables, and mount points, and assists you in using Anaconda or the gnome-disks disk utility to examine and partition the hard disk.

• Explains how to set up a dual-boot system so you can install Fedora/RHEL on a Windows system and boot either operating system.

• Discusses booting into a live Fedora session and installing Fedora from that session.

• Describes in detail how to use the new version of Anaconda, Fedora/RHEL’s installation program, to install Fedora/RHEL from an Install Image.

• Covers testing installation media for defects, setting boot command-line parameters (boot options), and creating a RAID array.

• Describes how to set up a VM (virtual machine) and install Fedora on the VM.

• 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.

Working with Fedora/RHEL

• Introduces the GNOME 3 Standard and Classic desktops (GUIs), and explains how to use desktop tools, including application and context menus, the Settings window, the Nautilus File Browser, and the GNOME terminal emulator.

• Covers the Bourne Again Shell (bash) in three chapters, including an entire chapter on shell programming, which 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 32 command-line utilities.

• Presents a tutorial on the vim and nano textual editors.

• Covers types of networks, network protocols (including IPv6), 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.


• Describes CentOS by virtue of that operating system’s compatibility with RHEL. CentOS (www.centos.org) is a free Linux distribution that has more long-term stability than Fedora but, unlike RHEL, CentOS is unsupported.

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 su to work with root privileges (become Superuser), and the advantages and dangers of working with escalated privileges.

• Goes into detail about using sudo to allow specific users to work with root privileges and customizing the way sudo works by editing the sudoers configuration file.

• Describes how to use the following tools to download and install software to keep a system up-to-date and to install new software:

Image Based on how you set up updates in the Software Update Preferences window, the Software Update window appears on the desktop to let you know when software updates are available. You can download and install updates from the Software Update window.

Image The Software window provides an easy way to select, download, and install a wide range of software packages.

Image The yum utility downloads and installs software packages from repositories on the Internet, keeping a system up-to-date and resolving dependencies as it processes the packages.

Image BitTorrent is a good choice for distributing large amounts of data such as the Fedora/RHEL Install Image. The more people who use BitTorrent to download a file, the faster it works.

• Covers graphical system administration tools, including the many tools available from the GNOME desktop.

• Explains system operation, including the boot process, rescue (single-user) and multiuser modes, and steps to take if the system crashes.

• Details the workings of the systemd init daemon, which replaces both the Upstart and System V init daemons.

• Explains how to set up and use the Cacti network monitoring tool to graph system and network information over time, including installing and setting up the LAMP (Linux, Apache, MariaDB/MySQL, and PHP) stack.

• Provides instructions on installing, setting up, and using a MariaDB/ MySQL relational database.

• Discusses setting up and repairing an XFS filesystem.

• Describes files, directories, and filesystems, including types of files and filesystems, fstab (the filesystem table), and automatically mounted filesystems, and explains how to fine-tune and check the integrity of filesystems.

• Covers backup utilities, including tar and cpio.

• Describes compression/archive utilities, including xz, gzip, bzip2, compress, and zip.

• Explains how to customize and build a Linux kernel.


• Helps you manage basic system security issues using ssh (secure shell), vsftpd (secure FTP server), Apache (Web server), firewalld and iptables (firewalls), and more.

• Includes a tutorial on using GPG (GNU Privacy Guard) to provide identification, secrecy, and message integrity in email and file sharing.

• Describes how to use the graphical firewall-config utility to protect the system.

• Provides instructions on using iptables to share an Internet connection over a LAN and to build advanced firewalls.

• Presents a complete section on SELinux (Security-Enhanced Linux), including instructions for using system-config-selinux to configure SELinux.

• Describes how to set up a chroot jail to help protect a server system.

• Explains how to use TCP wrappers to control who can access a server.

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; firewall-config, firewalld, and iptables; and NIS/LDAP.

• Describes how to set up a CUPS printer server.

• Explains how to set up and use a MariaDB/MySQL relational database.

• Describes how to set up and use a DHCP server.


• Provides a chapter on the Python programming language and a full chapter covering shell programming using bash, including many examples.


Chapter 1

Chapter 1 presents a brief history of Linux and explains some of the features that make it a cutting-edge operating system.

Part I

Part I, “Installing Fedora and Red Hat Enterprise Linux,” discusses how to install Fedora/RHEL Linux. Chapter 2 presents an overview of the process of installing Fedora/RHEL Linux, including hardware requirements, downloading and burning or writing the installation medium, and planning the layout of the hard disk. The “Conventions Used in This Book” section on page 26 details the typefaces and terminology used in this book. Chapter 3 is a step-by-step guide to installing Fedora and RHEL; it covers installing from an Install Image and from a live session (Fedora).

Part II

Part II, “Using 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; describes configuring the system using the Settings window; 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. The introduction to the command line includes information on terminal emulators, virtual consoles, correcting mistakes on the command line, a few basic utilities, and how to write and execute a simple shell script. Chapter 5 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. Chapter 6 discusses the Linux hierarchical filesystem, covering files, filenames, pathnames, working with directories, access permissions, and hard and symbolic links. Chapter 7 provides in-depth coverage of 32 useful utilities, and presents tutorials on the vim and nano text editors. Chapter 8 explains networks, network security, and the Internet, and discusses types of networks, subnets, protocols, addresses, hostnames, and various network utilities. A section covers the all-important IPv6 protocol. 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 IV.)

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. Do not skip “Conventions Used in This Book” (page 26), which explains the typographic and layout conventions used in this book. Both “Getting Help” (page 113), which explains how to get help using a GUI, and “Getting Help from the Command Line” (page 128), point out both local and remote sources of Linux and Fedora/RHEL documentation.

Part III

Part III, “System Administration,” goes into more detail about administrating the system. Chapter 9 extends the bash coverage from Chapter 5, 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 discusses core concepts, such as the use of su and sudo; working with root privileges; SELinux (Security-Enhanced Linux); system operation, including a discussion of the systemd init daemon; chroot jails; TCP wrappers; general information about how to set up a server; DHCP; and PAM. Chapter 11 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; the use of tune2fs to change filesystem parameters; and the XFS filesystem and related utilities. Chapter 12 explains how to keep a system up-to-date by downloading software from the Internet and installing it, including examples that use yum to perform these tasks. It also covers the RPM software packaging system and the use of the rpm utility. Finally, it explains how to use BitTorrent from the command line to download files. Chapter 13 explains how to set up the CUPS printing system so you can print on both local and remote systems. Chapter 14 details customizing and building a Linux kernel and includes information on GRUB 2. Chapter 15 covers additional administration tasks, including setting up user accounts, backing up files, scheduling automated tasks, tracking disk usage, and solving general problems. Chapter 16 explains how to set up a local area network (LAN), including both hardware (including wireless) and software configuration, and how to set up Cacti to monitor the network. Chapter 17 describes VMs (virtual machines), how to set up and work with VMs, and how to work with VMs in the cloud.

Part IV

Part IV goes into detail about setting up and running servers and connecting to them using clients. Where appropriate, these chapters include JumpStart sections, which get you off to a quick start in using clients and setting up servers. The chapters in Part IV cover the following clients/servers:

• OpenSSH—Set up an OpenSSH server and use ssh, 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.

• Email—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 maintain databases.

• 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.

• firewalld, firewall-config, and iptables—Set up a firewall to protect local systems and share a single Internet connection between systems on a LAN.

• Apache—Set up an HTTP server that serves Web pages, which browsers can then display. This chapter includes many suggestions for increasing Apache security.

Part V

Part V covers three 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 flexible and friendly Python programming language, including coverage of lists and dictionaries, using libraries, defining functions, regular expressions, and list comprehensions. Chapter 29 covers the widely used MariaDB/MySQL RDBMS (relational database management system), including installation, creating a database, adding a user, creating and modifying tables, joins, and adding data to the database.

Part VI

Part VI includes appendixes on regular expressions, helpful Web sites, system security including GPG, updating software using apt-get, and a map that indexes LPI’s Linux Essentials certification learning goals and CompTIA’s Linux+ exam objectives to the pages in this book that cover each topic. This part also includes an extensive Glossary with more than 500 entries plus the JumpStart index, the File Tree index, the Utility index, and the comprehensive Main index.