Page 3
Red Hat® Enterprise Linux® 6 Administration Real World Skills for Red Hat Administrators Sander van Vugt
Generating preview...
Red Hat® Enterprise Linux® 6 Administration Real World Skills for Red Hat Administrators Sander van Vugt
Senior Acquisitions Editor: Jeff Kellum Development Editor: Gary Schwartz Technical Editors: Floris Meester, Erno de Korte Production Editor: Rebecca Anderson Copy Editor: Kim Wimpsett Editorial Manager: Pete Gaughan Production Manager: Tim Tate Vice President and Executive Group Publisher: Richard Swadley Vice President and Publisher: Neil Edde Book Designer: Judy Fung and Bill Gibson Proofreaders: Louise Watson and Jennifer Bennett, Word One New York Indexer: J & J Indexing Project Coordinator, Cover: Katherine Crocker Cover Designer: Ryan Sneed Cover Image: © Jacob Wackerhausen / iStockPhoto Copyright © 2013 by John Wiley & Sons, Inc., Indianapolis, Indiana Published simultaneously in Canada ISBN: 978-1-118-30129-6 ISBN: 978-1-118-62045-8 (ebk.) ISBN: 978-1-118-42143-7 (ebk.) ISBN: 978-1-118-57091-3 (ebk.) 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) 646-8600. 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 ser- vices 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 Web site 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 Web site may provide or recommendations it may make. Fur- ther, readers should be aware that Internet Web sites 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 publishes in a variety of print and electronic formats and by print-on-demand. Some material included with standard print versions of this book may not be included in e-books or in print-on-demand. If this book refers to media such as a CD or DVD that is not included in the version you purchased, you may download this material at http://booksupport.wiley.com. For more information about Wiley products, visit www.wiley.com. Library of Congress Control Number: 2012954397 TRADEMARKS: Wiley, the Wiley logo, and the Sybex logo 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 is a registered trademark of Red Hat, Inc. Linux is a registered trademark of Linus Torvalds. All other trademarks are the property of their respective owners. John Wiley & Sons, Inc. is not associated with any product or vendor mentioned in this book. 10 9 8 7 6 5 4 3 2 1
Dear Reader, Thank you for choosing Red Hat Enterprise Linux 6 Administration: Real World Skills for Red Hat Administrators. This book is part of a family of premium-quality Sybex books, all of which are written by outstanding authors who combine practical experience with a gift for teaching. Sybex was founded in 1976. More than 30 years later, we’re still committed to producing consistently exceptional books. With each of our titles, we’re working hard to set a new standard for the industry. From the paper we print on to the authors we work with, our goal is to bring you the best books available. I hope you see all that reflected in these pages. I’d be very interested to hear your com- ments and get your feedback on how we’re doing. Feel free to let me know what you think about this or any other Sybex book by sending me an email at nedde@wiley.com. If you think you’ve found a technical error in this book, please visit http://sybex.custhelp.com. Customer feedback is critical to our efforts at Sybex. Best regards, Neil Edde Vice President and Publisher Sybex, an Imprint of Wiley
To Florence, my loving wife of 20 years who supports me and believes in everything I do. Chérie, I’m looking forward to spending the next 60 years of our lives together.
About the Author Sander van Vugt is an author of more than 50 technical books. Most of these books are in his native language of Dutch. Sander is also a technical instructor who works directly for major Linux vendors, such as Red Hat and SUSE. He specializes in high availability and performance issues in Linux. He has also built up a lot of experience in securing serv- ers with SELinux, especially on platforms that don’t support it natively. Sander has applied his skills in helping many companies all over the world who are using Linux. His work has taken him to amazing places like Greenland, Utah, Malaysia, and more. When not working, Sander likes to spend time with his two sons, Franck and Alex, and his beautiful wife, Florence. He also likes outdoor sports, in particular running, hiking, kayaking, and ice-skating. During these long hours of participating in sports, he thinks through the ideas for his next book and the projects on which he is currently working, which makes the actual writing process a lot easier and the project go more smoothly.
Acknowledgments Books of this size and depth succeed because of all the hard work put in by a team of pro- fessionals. I’m grateful for all the hard work put in by several people at Sybex on this proj- ect. Gary Schwartz was a great developmental editor. He helped keep things on track and provided excellent editorial guidance. The technical editors, Floris Meester and Erno de Korte, provided insightful input throughout the book. I appreciated the meticulous atten- tion to detail provided by Rebecca Anderson, the production editor for this book. Last, but certainly not least, I want to thank Jeff Kellum, the acquisitions editor, for having the faith in me to write this book for Sybex.
Contents at a Glance Introduction xxiii Part I Getting Familiar with Red Hat Enterprise Linux 1 Chapter 1 Getting Started with Red Hat Enterprise Linux 3 Chapter 2 Finding Your Way on the Command Line 41 Part II Administering Red Hat Enterprise Linux 67 Chapter 3 Performing Daily System Administration Tasks 69 Chapter 4 Managing Software 99 Chapter 5 Configuring and Managing Storage 121 Chapter 6 Connecting to the Network 155 Part III Securing Red Hat Enterprise Linux 187 Chapter 7 Working with Users, Groups, and Permissions 189 Chapter 8 Understanding and Configuring SELinux 229 Chapter 9 Working with KVM Virtualization 245 Chapter 10 Securing Your Server with iptables 269 Chapter 11 Setting Up Cryptographic Services 293 Part IV Networking Red Hat Enterprise Linux 313 Chapter 12 Configuring OpenLDAP 315 Chapter 13 Configuring Your Server for File Sharing 333 Chapter 14 Configuring DNS and DHCP 355 Chapter 15 Setting Up a Mail Server 375 Chapter 16 Configuring Apache on Red Hat Enterprise Linux 385 Part V Advanced Red Hat Enterprise Linux Configuration 411 Chapter 17 Monitoring and Optimizing Performance 413 Chapter 18 Introducing Bash Shell Scripting 467
Chapter 19 Understanding and Troubleshooting the Boot Procedure 505 Chapter 20 Introducing High-Availability Clustering 529 Chapter 21 Setting Up an Installation Server 561 Appendix A Hands-On Labs 577 Appendix B Answers to Hands-On Labs 589 Glossary 607 Index 625
Contents Introduction xxiii Part I Getting Familiar with Red Hat Enterprise Linux 1 Chapter 1 Getting Started with Red Hat Enterprise Linux 3 Linux, Open Source, and Red Hat 4 Origins of Linux 4 Distributions 5 Fedora 6 Red Hat Enterprise Linux and Related Products 7 Red Hat Enterprise Linux Server Edition 7 Red Hat Enterprise Linux Workstation Edition 8 Red Hat Add-Ons 8 Red Hat Directory Server 9 Red Hat Enterprise Virtualization 9 JBoss Enterprise Middleware 9 Red Hat Cloud 9 Installing Red Hat Enterprise Linux Server 9 Exploring the GNOME User Interface 33 Exploring the Applications Menu 34 Exploring the Places Menu 35 Exploring the System Menu 36 Summary 39 Chapter 2 Finding Your Way on the Command Line 41 Working with the Bash Shell 42 Getting the Best of Bash 42 Useful Bash Key Sequences 43 Working with Bash History 44 Performing Basic File System Management Tasks 45 Working with Directories 45 Working with Files 46 Piping and Redirection 50 Piping 50 Redirection 51
x Contents Finding Files 55 Working with an Editor 56 Vi Modes 57 Saving and Quitting 57 Cut, Copy, and Paste 58 Deleting Text 58 Replacing Text 58 Using sed for the Replacement of Text 59 Getting Help 61 Using man to Get Help 61 Using the --help Option 65 Getting Information on Installed Packages 65 Summary 66 Part II Administering Red Hat Enterprise Linux 67 Chapter 3 Performing Daily System Administration Tasks 69 Performing Job Management Tasks 70 System and Process Monitoring and Management 72 Managing Processes with ps 73 Sending Signals to Processes with the kill Command 74 Using top to Show Current System Activity 76 Managing Process Niceness 80 Scheduling Jobs 82 Mounting Devices 83 Working with Links 87 Creating Backups 88 Managing Printers 89 Setting Up System Logging 91 Setting Up Rsyslog 92 Common Log Files 94 Setting Up Logrotate 96 Summary 98 Chapter 4 Managing Software 99 Understanding RPM 100 Understanding Meta Package Handlers 101 Creating Your Own Repositories 103 Managing Repositories 104 RHN and Satellite 106 Installing Software with Yum 109 Querying Software 115 Extracting Files from RPM Packages 118 Summary 119
Contents xi Chapter 5 Configuring and Managing Storage 121 Understanding Partitions and Logical Volumes 122 Creating Partitions 123 Creating File Systems 129 File Systems Overview 129 Creating File Systems 131 Changing File System Properties 132 Checking the File System Integrity 134 Mounting File Systems Automatically Through fstab 135 Working with Logical Volumes 139 Creating Logical Volumes 139 Resizing Logical Volumes 143 Working with Snapshots 146 Replacing Failing Storage Devices 149 Creating Swap Space 149 Working with Encrypted Volumes 151 Summary 154 Chapter 6 Connecting to the Network 155 Understanding NetworkManager 156 Working with Services and Runlevels 156 Configuring the Network with NetworkManager 158 Working with system-config-network 160 Understanding NetworkManager Configuration Files 161 Understanding Network Service Scripts 164 Configuring Networking from the Command Line 164 Troubleshooting Networking 169 Setting Up IPv6 173 Configuring SSH 174 Enabling the SSH Server 175 Using the SSH Client 177 Using PuTTY on Windows Machines 177 Configuring Key-Based SSH Authentication 178 Using Graphical Applications with SSH 181 Using SSH Port Forwarding 182 Configuring VNC Server Access 183 Summary 185 Part III Securing Red Hat Enterprise Linux 187 Chapter 7 Working with Users, Groups, and Permissions 189 Managing Users and Groups 190 Commands for User Management 190 Managing Passwords 192
xii Contents Modifying and Deleting User Accounts 193 Behind the Commands: Configuration Files 194 Creating Groups 198 Using Graphical Tools for User and Group Management 201 Using External Authentication Sources 203 Understanding the Authentication Process 208 Understanding sssd 208 Understanding nsswitch 209 Understanding Pluggable Authentication Modules 210 Managing Permissions 212 Understanding the Role of Ownership 212 Basic Permissions: Read, Write, and Execute 214 Advanced Permissions 216 Working with Access Control Lists 220 Setting Default Permissions with umask 225 Working with Attributes 226 Summary 227 Chapter 8 Understanding and Configuring SELinux 229 Understanding SELinux 230 What Is SELinux? 231 Understanding the Type Context 231 Selecting the SELinux Mode 233 Working with SELinux Context Types 235 Configuring SELinux Policies 237 Working with SELinux Modules 238 Setting Up SELinux with system-config-selinux 239 Troubleshooting SELinux 239 Summary 244 Chapter 9 Working with KVM Virtualization 245 Understanding the KVM Virtualization Architecture 246 Red Hat KVM Virtualization 246 Red Hat Enterprise Virtualization 247 Preparing Your Host for KVM Virtualization 248 Installing a KVM Virtual Machine 249 Managing KVM Virtual Machines 255 Managing Virtual Machines with Virtual Machine Manager 256 Managing Virtual Machines from the virsh Interface 262 Understanding KVM Networking 263 Summary 268
Contents xiii Chapter 10 Securing Your Server with iptables 269 Understanding Firewalls 270 Setting Up a Firewall with system-config-firewall 271 Allowing Services 272 Trusted Interfaces 275 Masquerading 275 Configuration Files 278 Setting Up a Firewall with iptables 279 Understanding Tables, Chains, and Rules 280 Understanding How a Rule Is Composed 280 Configuration Example 281 Advanced iptables Configuration 287 Configuring Logging 287 The Limit Module 289 Configuring NAT 289 Summary 292 Chapter 11 Setting Up Cryptographic Services 293 Introducing SSL 294 Proof of Authenticity: the Certificate Authority 295 Managing Certificates with openssl 296 Creating a Signing Request 302 Working with GNU Privacy Guard 302 Creating GPG Keys 303 Key Transfer 305 Managing GPG Keys 307 Encrypting Files with GPG 308 GPG Signing 310 Signing RPM Files 310 Summary 312 Part IV Networking Red Hat Enterprise Linux 313 Chapter 12 Configuring OpenLDAP 315 Understanding OpenLDAP 316 Types of Information in OpenLDAP 316 The LDAP Name Scheme 316 Replication and Referrals 317 Configuring a Base OpenLDAP Server 318 Installing and Configuring OpenLDAP 318 Populating the OpenLDAP Database 320 Creating the Base Structure 320 Understanding the Schema 323 Managing Linux Users and Groups in LDAP 326
xiv Contents Using OpenLDAP for Authentication 332 Summary 332 Chapter 13 Configuring Your Server for File Sharing 333 Configuring NFS4 334 Setting Up NFSv4 335 Mounting an NFS Share 337 Making NFS Mounts Persistent 338 Configuring Automount 338 Configuring Samba 342 Setting Up a Samba File Server 342 Samba and SELinux 345 Samba Advanced Authentication Options 346 Accessing Samba Shares 346 Offering FTP Services 348 File Sharing and SELinux 351 Summary 352 Chapter 14 Configuring DNS and DHCP 355 Understanding DNS 356 The DNS Hierarchy 356 DNS Server Types 357 The DNS Lookup Process 358 DNS Zone Types 359 Setting Up a DNS Server 359 Setting Up a Cache-Only Name Server 359 Setting Up a Primary Name Server 361 Setting Up a Secondary Name Server 368 Understanding DHCP 369 Setting Up a DHCP Server 370 Summary 374 Chapter 15 Setting Up a Mail Server 375 Using the Message Transfer Agent 376 Understanding the Mail Delivery Agent 377 Understanding the Mail User Agent 377 Setting Up Postfix as an SMTP Server 377 Working with Mutt 378 Basic Configuration 380 Internet Configuration 382 Configuring Dovecot for POP and IMAP 383 Further Steps 384 Summary 384
Contents xv Chapter 16 Configuring Apache on Red Hat Enterprise Linux 385 Configuring the Apache Web Server 386 Creating a Basic Website 386 Understanding the Apache Configuration Files 387 Apache Log Files 393 Apache and SELinux 393 Getting Help 395 Working with Virtual Hosts 396 Securing the Web Server with TLS Certificates 399 Configuring Authentication 404 Setting Up Authentication with .htpasswd 405 Configuring LDAP Authentication 406 Setting Up MySQL 407 Summary 409 Part V Advanced Red Hat Enterprise Linux Configuration 411 Chapter 17 Monitoring and Optimizing Performance 413 Interpreting What’s Going On: The top Utility 414 CPU Monitoring with top 415 Memory Monitoring with top 417 Process Monitoring with top 419 Analyzing CPU Performance 420 Understanding CPU Performance 421 Context Switches and Interrupts 421 Using vmstat 425 Analyzing Memory Usage 425 Page Size 425 Active vs. Inactive Memory 426 Kernel Memory 427 Using ps for Analyzing Memory 430 Monitoring Storage Performance 433 Understanding Disk Activity 434 Finding Most Busy Processes with iotop 438 Setting and Monitoring Drive Activity with hdparm 440 Understanding Network Performance 440 Optimizing Performance 446 Using a Simple Performance Optimization Test 447 CPU Tuning 449 Tuning Memory 451 Optimizing Interprocess Communication 453
xvi Contents Tuning Storage Performance 455 Network Tuning 459 Optimizing Linux Performance Using cgroups 464 Summary 466 Chapter 18 Introducing Bash Shell Scripting 467 Getting Started 468 Elements of a Good Shell Script 468 Executing the Script 471 Working with Variables and Input 472 Understanding Variables 472 Variables, Subshells, and Sourcing 474 Working with Script Arguments 476 Asking for Input 480 Using Command Substitution 482 Substitution Operators 483 Changing Variable Content with Pattern Matching 485 Performing Calculations 489 Using Control Structures 491 Using if...then...else 493 Using case 496 Using while 498 Using until 499 Using for 500 Summary 503 Chapter 19 Understanding and Troubleshooting the Boot Procedure 505 Introduction to Troubleshooting the Boot Procedure 506 Configuring Booting with GRUB 507 Understanding the grub.conf Configuration File 507 Changing Boot Options 510 Using the GRUB Command Line 513 Reinstalling GRUB 514 GRUB behind the Scenes 514 Common Kernel Management Tasks 516 Analyzing Availability of Kernel Modules 517 Loading and Unloading Kernel Modules 518 Loading Kernel Modules with Specific Options 519 Upgrading the Kernel 521 Configuring Service Startup with Upstart 521 Basic Red Hat Enterprise Linux Troubleshooting 524 Summary 527
Contents xvii Chapter 20 Introducing High-Availability Clustering 529 Understanding High-Availability Clustering 530 The Workings of High Availability 530 High-Availability Requirements 531 Red Hat High-Availability Add-on Software Components 534 Configuring Cluster-Based Services 535 Setting Up Bonding 535 Setting Up Shared Storage 537 Installing the Red Hat High Availability Add-On 541 Building the Initial State of the Cluster 542 Configuring Additional Cluster Properties 546 Configuring a Quorum Disk 549 Setting Up Fencing 551 Creating Resources and Services 554 Troubleshooting a Nonoperational Cluster 558 Configuring GFS2 File Systems 559 Summary 560 Chapter 21 Setting Up an Installation Server 561 Configuring a Network Server As an Installation Server 562 Setting Up a TFTP and DHCP Server for PXE Boot 563 Installing the TFTP Server 564 Configuring DHCP for PXE Boot 565 Creating the TFTP PXE Server Content 565 Creating a Kickstart File 568 Using a Kickstart File to Perform an Automated Installation 568 Modifying the Kickstart File with system-config-kickstart 570 Making Manual Modifications to the Kickstart File 573 Summary 576 Appendix A Hands-On Labs 577 Appendix B Answers to Hands-On Labs 589 Glossary 607 Index 625
Showing the first 19 pages. Download the document to see it all.
No comments yet. Be the first!
Comments (0)
No comments yet. Be the first!