fedora and red hat - A Practical Guide to Fedora and Red Hat Enterprise Linux FIFTH EDITION Mark G Sobell Upper Saddle River NJ Boston Indianapolis San

fedora and red hat - A Practical Guide to Fedora and Red...

This preview shows page 1 out of 1204 pages.

You've reached the end of your free preview.

Want to read all 1204 pages?

Unformatted text preview: ™ A Practical Guide to Fedora and Red Hat Enterprise Linux ® ® FIFTH EDITION Mark G. Sobell Upper Saddle River, NJ • Boston • Indianapolis • San Francisco New York • Toronto • Montreal • London • Munich • Paris • Madrid Capetown • Sydney • Tokyo • Singapore • Mexico City From the Library of Skyla Walker Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and the publisher was aware of a trademark claim, the designations have been printed with initial capital letters or in all capitals. The author and publisher have taken care in the preparation of this book, but make no expressed or implied warranty of any kind and assume no responsibility for errors or omissions. No liability is assumed for incidental or consequential damages in connection with or arising out of the use of the information or programs contained herein. The publisher offers excellent discounts on this book when ordered in quantity for bulk purchases or special sales, which may include electronic versions and/or custom covers and content particular to your business, training goals, marketing focus, and branding interests. For more information, please contact: U.S. Corporate and Government Sales (800) 382-3419 [email protected] For sales outside the United States, please contact: International Sales [email protected] Visit us on the Web: informit.com/ph Library of Congress Cataloging-in-Publication Data Sobell, Mark G. A practical guide to Fedora and Red Hat Enterprise Linux / Mark G. Sobell.—5th ed. p. cm. Includes index. ISBN 978-0-13-706088-7 (pbk.) 1. Linux. 2. Operating systems (Computers) I. Title. QA76.76.O63S5945 2010 005.4'32—dc22 2009053421 Copyright © 2010 Mark G. Sobell All rights reserved. Printed in the United States of America. This publication is protected by copyright, and permission must be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permissions, write to: Pearson Education, Inc. Rights and Contracts Department 501 Boylston Street, Suite 900 Boston, MA 02116 Fax: (617) 671-3447 ISBN-13: 978-0-13-706088-7 ISBN-10: 0-13-706088-2 Text printed in the United States at Edwards Brothers in Ann Arbor, Michigan. First printing, February 2010 From the Library of Skyla Walker Brief Contents Contents xiii Preface xxxvii 1 Welcome to Linux 1 PART I Installing Fedora and Red Hat Enterprise Linux 21 2 3 Installation Overview 23 Step-by-Step Installation 51 PART II Getting Started with Fedora and Red Hat Enterprise Linux 87 4 5 6 7 Introduction to Fedora and Red Hat Enterprise Linux 89 The Linux Utilities 147 The Linux Filesystem 187 The Shell 223 PART III Digging into Fedora and Red Hat Enterprise Linux 253 8 Linux GUIs: X and GNOME 255 9 The Bourne Again Shell 279 10 Networking and the Internet 357 xi From the Library of Skyla Walker xii Brief Contents PART IV 11 12 13 14 15 16 17 PART V 18 19 20 21 22 23 24 25 26 401 Using Clients and Setting Up Servers 619 OpenSSH: Secure Network Communication 621 FTP: Transferring Files Across a Network 643 sendmail: Setting Up Mail Clients, Servers, and More 669 NIS and LDAP 695 NFS: Sharing Filesystems 727 Samba: Integrating Linux and Windows 749 DNS/BIND: Tracking Domain Names and Addresses 773 iptables: Setting Up a Firewall 819 Apache (httpd): Setting Up a Web Server 841 PART VI 27 28 System Administration System Administration: Core Concepts 403 Files, Directories, and Filesystems 467 Downloading and Installing Software 497 Printing with CUPS 519 Rebuilding the Linux Kernel 543 Administration Tasks 555 Configuring and Monitoring a LAN 595 Programming Tools Programming the Bourne Again Shell The Perl Scripting Language 975 PART VII Appendixes A Regular Expressions 1023 B Help 1033 C Security 1043 D The Free Software Definition 885 887 1021 1063 Glossary 1067 Index 1117 From the Library of Skyla Walker Contents Preface xxxvii Chapter 1: Welcome to Linux 1 The GNU–Linux Connection 2 The History of GNU–Linux 2 The Code Is Free 4 Have Fun! 5 The Linux 2.6 Kernel 5 The Heritage of Linux: UNIX 5 What Is So Good About Linux? 6 Why Linux Is Popular with Hardware Companies and Developers 7 Linux Is Portable 8 Standards 8 The C Programming Language 9 Overview of Linux 10 Linux Has a Kernel Programming Interface 10 Linux Can Support Many Users 10 Linux Can Run Many Tasks 11 Linux Provides a Secure Hierarchical Filesystem 11 The Shell: Command Interpreter and Programming Language 12 A Large Collection of Useful Utilities 14 Interprocess Communication 14 System Administration 14 xiii xiv Contents Additional Features of Linux 14 GUIs: Graphical User Interfaces 15 (Inter)Networking Utilities 16 Software Development 16 Conventions Used in This Book 16 Chapter Summary 19 Exercises 19 PART I Installing Fedora and Red Hat Enterprise Linux 21 Chapter 2: Installation Overview 23 The Desktop Live CD and the Install DVD 24 Planning the Installation 24 Considerations 25 Requirements 25 Processor Architecture 26 Interfaces: Installer and Installed System 28 Which Are You Installing: Fedora or Red Hat Enterprise Linux? 28 Upgrading an Existing Fedora/RHEL System Versus Installing a Fresh Copy Setting Up the Hard Disk 30 RAID 37 LVM: Logical Volume Manager 38 The Installation Process 39 The Medium: Where Is the Source Data? 40 Downloading a CD/DVD (FEDORA ) 41 The Easy Way to Download a CD ISO Image File 41 Finding a Mirror Site to Download From 42 Using BitTorrent to Download a CD/DVD ISO Image File 44 Checking and Burning the CD/DVD 45 Checking the File 45 Burning the CD/DVD 46 Rescue Selection of the Install DVD 46 Gathering Information About the System 46 Finding the Installation Manual 47 More Information 48 Chapter Summary 48 Exercises 49 Advanced Exercises 49 Chapter 3: Step-by-Step Installation Running a Fedora Live Session 52 Booting the System 52 51 29 Contents xv Installing Fedora/RHEL 55 Installing from a Live Session 55 Installing/Upgrading from the Install DVD 55 The Anaconda Installer 57 Firstboot: When You Reboot 66 Initializing Databases and Updating the System 67 Installation Tasks 68 Modifying Boot Parameters (Options) 68 Partitioning the Disk 71 LVs: Logical Volumes 73 Partitions 76 palimpsest: The GNOME Disk Utility (FEDORA) 78 Using the Kickstart Configurator 82 Setting Up a Dual-Boot System 82 The X Window System 84 gnome-display-properties: Configures the Display 84 More Information 85 Chapter Summary 85 Exercises 85 Advanced Exercises 86 PART II Getting Started with Fedora and Red Hat Enterprise Linux 87 Chapter 4: Introduction to Fedora and Red Hat Enterprise Linux 89 Curbing Your Power (Superuser/root Privileges) 90 A Tour of the Fedora/RHEL Desktop 90 Logging In on the System 91 Introduction 92 Launching Programs from the Desktop 93 Switching Workspaces 95 Setting Personal Preferences 96 Mouse Preferences 97 Working with Windows 98 Using Nautilus to Work with Files 98 The Update Applet 104 Changing Appearance (Themes) 105 Desktop Effects (FEDORA) 108 Session Management 108 Getting Help 108 Feel Free to Experiment 109 Logging Out 109 xvi Contents Getting the Most Out of the Desktop 109 GNOME Desktop Terminology 110 Opening Files 110 Panels 111 The Main Menu 114 Windows 115 The Object Context Menu 119 Updating, Installing, and Removing Software Packages 122 Updates (FEDORA) 122 Add/Remove Software 123 Where to Find Documentation 124 GNOME Help Browser 125 man: Displays the System Manual 125 apropos: Searches for a Keyword 127 info: Displays Information About Utilities 127 The ––help Option 130 HOWTOs: Finding Out How Things Work 130 Getting Help with the System 131 More About Logging In 132 The Login Screen 133 What to Do If You Cannot Log In 134 Logging In Remotely: Terminal Emulators, ssh, and Dial-Up Connections Logging In from a Terminal (Emulator) 135 Changing Your Password 136 Using Virtual Consoles 137 Working from the Command Line 138 Correcting Mistakes 138 Repeating/Editing Command Lines 140 Controlling Windows: Advanced Operations 141 Changing the Input Focus 141 Changing the Resolution of the Display 142 The Window Manager 142 Chapter Summary 143 Exercises 144 Advanced Exercises 145 Chapter 5: The Linux Utilities 147 Special Characters 148 Basic Utilities 149 ls: Lists the Names of Files 149 cat: Displays a Text File 149 rm: Deletes a File 150 less Is more: Display a Text File One Screen at a Time hostname: Displays the System Name 151 150 135 Contents xvii Working with Files 151 cp: Copies a File 151 mv: Changes the Name of a File 152 lpr: Prints a File 153 grep: Searches for a String 153 head: Displays the Beginning of a File 154 tail: Displays the End of a File 154 sort: Displays a File in Order 155 uniq: Removes Duplicate Lines from a File 156 diff: Compares Two Files 157 file: Tests the Contents of a File 157 | (Pipe): Communicates Between Processes 158 Four More Utilities 159 echo: Displays Text 159 date: Displays the Time and Date 159 script: Records a Shell Session 160 unix2dos: Converts Linux and Macintosh Files to Windows Format Compressing and Archiving Files 161 bzip2: Compresses a File 162 bunzip2 and bzcat: Decompress a File 162 gzip: Compresses a File 163 tar: Packs and Unpacks Archives 163 Locating Commands 166 which and whereis: Locate a Utility 166 apropos: Searches for a Keyword 167 locate: Searches for a File 168 Obtaining User and System Information 168 who: Lists Users on the System 169 finger: Lists Users on the System 169 w: Lists Users on the System 171 Communicating with Other Users 172 write: Sends a Message 172 mesg: Denies or Accepts Messages 173 Email 174 Tutorial: Creating and Editing a File Using vim 174 Starting vim 175 Command and Input Modes 176 Entering Text 177 Getting Help 178 Ending the Editing Session 181 The compatible Parameter 181 Chapter Summary 181 Exercises 184 Advanced Exercises 185 161 xviii Contents Chapter 6: The Linux Filesystem 187 The Hierarchical Filesystem 188 Directory Files and Ordinary Files 188 Filenames 189 The Working Directory 192 Your Home Directory 192 Pathnames 193 Absolute Pathnames 193 Relative Pathnames 194 Directory Commands 195 mkdir: Creates a Directory 195 Important Standard Directories and Files 198 Working with Directories 200 rmdir: Deletes a Directory 200 Using Pathnames 201 mv, cp: Move or Copy Files 201 mv: Moves a Directory 202 Access Permissions 202 ls –l: Displays Permissions 203 chmod: Changes Access Permissions 204 Setuid and Setgid Permissions 205 Directory Access Permissions 206 ACLs: Access Control Lists 207 Enabling ACLs 208 Working with Access Rules 208 Setting Default Rules for a Directory 211 Links 212 Hard Links 214 Symbolic Links 216 rm: Removes a Link 218 Chapter Summary 218 Exercises 220 Advanced Exercises 222 Chapter 7: The Shell 223 The Command Line 224 Syntax 224 Processing the Command Line 227 Executing the Command Line 229 Editing the Command Line 229 Contents xix Standard Input and Standard Output 230 The Screen as a File 230 The Keyboard and Screen as Standard Input and Standard Output Redirection 232 Pipes 238 Running a Program in the Background 241 Filename Generation/Pathname Expansion 243 The ? Special Character 243 The * Special Character 244 The [ ] Special Characters 245 Builtins 247 Chapter Summary 248 Utilities and Builtins Introduced in This Chapter 249 Exercises 249 Advanced Exercises 251 PART III Digging into Fedora and Red Hat Enterprise Linux 253 Chapter 8: Linux GUIs: X and GNOME X Window System 256 Using X 258 Desktop Environments/Managers 263 The Nautilus File Browser Window 264 The View Pane 265 The Side Pane 265 Control Bars 266 Menubar 267 The Nautilus Spatial View 270 GNOME Utilities 272 Font Preferences (FEDORA) 272 Pick a Font Window (FEDORA) 272 Pick a Color Window 273 Run Application Window 274 Searching for Files 274 GNOME Terminal Emulator/Shell 275 Chapter Summary 276 Exercises 277 Advanced Exercises 277 255 231 xx Contents Chapter 9: The Bourne Again Shell Background 280 Shell Basics 281 Startup Files 281 Commands That Are Symbols 284 Redirecting Standard Error 284 Writing a Simple Shell Script 286 Separating and Grouping Commands 290 Job Control 294 Manipulating the Directory Stack 296 Parameters and Variables 299 User-Created Variables 300 Variable Attributes 303 Keyword Variables 305 Special Characters 313 Processes 314 Process Structure 314 Process Identification 314 Executing a Command 316 History 316 Variables That Control History 316 Reexecuting and Editing Commands 318 The Readline Library 326 Aliases 332 Single Versus Double Quotation Marks in Aliases Examples of Aliases 334 Functions 335 Controlling bash Features and Options 338 Command-Line Options 338 Shell Features 338 Processing the Command Line 342 History Expansion 342 Alias Substitution 342 Parsing and Scanning the Command Line 342 Command-Line Expansion 343 Chapter Summary 351 Exercises 353 Advanced Exercises 355 279 333 Contents xxi Chapter 10: Networking and the Internet Types of Networks and How They Work 359 Broadcast Networks 360 Point-to-Point Networks 360 Switched Networks 360 LAN: Local Area Network 361 WAN: Wide Area Network 362 Internetworking Through Gateways and Routers 362 Network Protocols 365 Host Address 367 CIDR: Classless Inter-Domain Routing 371 Hostnames 372 Communicate Over a Network 374 finger: Displays Information About Remote Users 374 Sending Mail to a Remote User 375 Mailing List Servers 376 Network Utilities 376 Trusted Hosts 376 OpenSSH Tools 377 telnet: Logs In on a Remote System 377 ftp: Transfers Files Over a Network 379 ping: Tests a Network Connection 379 traceroute: Traces a Route Over the Internet 380 host and dig: Query Internet Nameservers 382 jwhois: Looks Up Information About an Internet Site 382 Distributed Computing 383 The Client/Server Model 384 DNS: Domain Name Service 385 Ports 387 NIS: Network Information Service 387 NFS: Network Filesystem 387 Internet Services 388 Proxy Servers 391 RPC Network Services 391 Usenet 392 WWW: World Wide Web 395 URL: Uniform Resource Locator 396 Browsers 396 Search Engines 396 Chapter Summary 397 Exercises 398 Advanced Exercises 399 357 xxii Contents PART IV System Administration 401 Chapter 11: System Administration: Core Concepts System Administrator and Superuser 405 System Administration Tools 407 Rescue Mode 411 Avoiding a Trojan Horse 412 Getting Help 413 SELinux 414 More Information 415 config: The SELinux Configuration File 415 getenforce, setenforce, and sestatus: Work with SELinux 416 Setting the Targeted Policy with system-config-selinux 416 The Upstart Event-Based init Daemon (FEDORA) 417 Definitions 418 Jobs 420 System Operation 424 Runlevels 424 Booting the System 425 Init Scripts: Start and Stop System Services 426 Single-User Mode 430 Going to Multiuser Mode 431 Graphical Multiuser Mode 431 Logging In 431 Logging Out 433 Bringing the System Down 433 Crash 436 System Administration Utilities 436 Fedora/RHEL Configuration Tools 437 Command-Line Utilities 438 Setting Up a Server 441 Standard Rules in Configuration Files 441 rpcinfo: Displays Information About rpcbind 443 The xinetd Superserver 445 Securing a Server 447 DHCP: Configures Hosts 451 nsswitch.conf: Which Service to Look at First 455 How nsswitch.conf Works 455 PAM 458 More Information 459 Configuration Files, Module Types, and Control Flags 459 Example 462 Modifying the PAM Configuration 463 Chapter Summary 464 Exercises 464 Advanced Exercises 465 403 Contents Chapter 12: Files, Directories, and Filesystems xxiii 467 Important Files and Directories 468 File Types 480 Ordinary Files, Directories, Links, and Inodes 481 Special Files 482 Filesystems 485 mount: Mounts a Filesystem 487 umount: Unmounts a Filesystem 490 fstab: Keeps Track of Filesystems 490 fsck: Checks Filesystem Integrity 492 tune2fs: Changes Filesystem Parameters 492 RAID Filesystem 494 Chapter Summary 495 Exercises 495 Advanced Exercises 496 Chapter 13: Downloading and Installing Software 497 yum: Keeps the System Up-to-Date 498 Configuring yum 498 Using yum to Update, Install, and Remove Packages 500 yum Groups 503 Other yum Commands 504 yum-updatesd: Runs yum Automatically 504 Upgrading a System with yum 505 Downloading rpm Package Files with yumdownloader 505 Adding and Removing Software Packages 505 pirut: Adds and Removes Software Packages (RHEL) 505 BitTorrent 507 rpm: Red Hat Package Manager 510 Querying Packages and Files 511 Installing, Upgrading, and Removing Packages 512 Installing a Linux Kernel Binary 512 Installing Non-rpm Software 513 The /opt and /usr/local Directories 513 GNU Configure and Build System 513 Keeping Software Up-to-Date 515 Bugs 515 Errata 516 Red Hat Network (RHEL ) 516 wget: Downloads Files Noninteractively 517 Chapter Summary 518 Exercises 518 Advanced Exercises 518 xxiv Contents Chapter 14: Printing with CUPS 519 Introduction 520 Prerequisites 520 More Information 521 Notes 521 JumpStart I: Configuring a Local Printer 521 system-config-printer: Configuring a Printer 522 Configuration Selections 522 Setting Up a Remote Printer 524 JumpStart II: Setting Up a Local or Remote Printer Using the CUPS Web Interface 527 Traditional UNIX Printing 530 Configuring Printers 532 The CUPS Web Interface 532 CUPS on the Command Line 533 Sharing CUPS Printers 537 Printing from Windows 538 Printing Using CUPS 538 Printing Using Samba 539 Printing to Windows 540 Chapter Summary 540 Exercises 541 Advanced Exercises 541 Chapter 15: Rebuilding the Linux Kernel Preparing the Source Code 544 Locating the Kernel Source Code 544 Installing the Kernel Source Code 545 Read the Documentation 546 Configuring and Compiling the Linux Kernel 547 Cleaning the Source Tree 547 Configuring the Linux Kernel 547 Compiling the Kernel 549 Using Loadable Kernel Modules 549 Installing the Kernel and Associated Files 550 Rebooting the System 550 Boot Loader 551 grub: The Linux Loader 551 dmesg: Displays Kernel Messages 553 Chapter Summary 553 Exercises 554 Advanced Exercises 554 543 Contents Chapter 16: Administration Tasks 555 Configuring User and Group Accounts 556 system-config-users: Manages User Accounts 556 useradd: Adds a User Account 557 userdel: Removes a User Account 558 groupadd: Adds a Group 558 Backing Up Files 558 Choosing a Backup Medium 559 Backup Utilities 560 Performing a Simple Backup 562 dump , restore: Back Up and Restore Filesystems 563 Scheduling Tasks 565 crond and crontab: Schedule Routine Tasks 565 at: Runs Occasional Tasks 565 System Reports 566 vmstat: Reports Virtual Memory Statistics 566 top: Lists Processes Using the Most Resources 567 parted: Reports on and Partitions a Hard Disk 568 Keeping Users Informed 572 Creating Problems 572 Failing to Perform Regular Backups 573 Not Reading and Following Instructions 573 Failing to Ask for Help When Instructions Are Not Clear Deleting or Mistyping a Critical File 573 Solving Problems 574 Helping When a User Cannot Log In 574 Speeding Up the System 575 lsof: Finds Open Files 576 Keeping a Machine Log 576 Keeping the System Secure 577 Log Files and Mail for root 577 Monitoring Disk Usage 578 logrotate: Manages Log Files 579 Removing Unused Space from Directories 581 Disk Quota System 582 rsyslogd: Logs System Messages 582 MySQL 584 More Information 585 Terminology 585 Syntax and Conventions 585 Prerequisites 585 Notes 586 Jumpstart: Setting Up MySQL 586 Options 587 The .my.cnf Configuration File 587 Working with MySQL 588 573 xxv xxvi Contents Chapter Summary 592 Exercises 593 Advanced Exercises 593 Chapter 17: Configuring and Monitoring a LAN 595 Setting Up the Hardware 596 Connecting the Computers 596 Gateways and Routers 597 NIC: Network Interface Card 597 Configuring the Systems 598 NetworkManager: Configures Network Connections 599 The NetworkManager Applet 599 The Network Configuration Window (system-conf...
View Full Document

  • Spring '17
  • John.DOe
  • The American, Red Hat, Red Hat Enterprise Linux, Advanced Exercises

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture