Tải bản đầy đủ (.pdf) (700 trang)

linux professional institute certification study guide

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (5.87 MB, 700 trang )


FFIRS.indd vi

3/26/11 7:42:19 PM


LPIC-2
Linux Professional Institute
Certification
Study Guide

Roderick W. Smith

FFIRS.indd i

3/26/11 7:42:16 PM


Senior Acquisitions Editor: Jeff Kellum
Development Editor: Jennifer Leland
Technical Editors: Ross Brunson and Don Corbet
Production Editor: Liz Britten
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
Media Project Manager 1: Laura Moss-Hollister
Media Associate Producer: Doug Kuhn
Media Quality Assurance: Marilyn Hummel
Book Designers: Judy Fung, Bill Gibson


Proofreader: WordOne, New York
Indexer: Ted Laux
Project Coordinator, Cover: Katie Crocker
Cover Designer: Ryan Sneed
Copyright © 2011 by Wiley Publishing, Inc., Indianapolis, Indiana
Published simultaneously in Canada
ISBN: 978-1-118-00015-1
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 />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
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. Further, 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 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 Cataloging-in-Publication Data.

Smith, Roderick W.
LPIC-2 : Linux Professional Institute certification study guide (exams 201 and 202) / Roderick W. Smith.
p. cm.
ISBN-13: 978-1-118-00015-1 (pbk.)
ISBN-10: 1-118-00015-3 (pbk.)
ISBN: 978-1-118-00042-4 (ebk)
ISBN: 978-1-118-00044-8 (ebk)
ISBN: 978-1-118-00043-1 (ebk)
1. Electronic data processing personnel—Certification. 2. Linux—Examinations—Study guides. I. Title.
QA76.3.S4774 2011
005.4'32—dc22
2011005893
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. All other trademarks are the property of their respective owners. Wiley Publishing, Inc., is not
associated with any product or vendor mentioned in this book.
10 9 8 7 6 5 4 3 2 1

FFIRS.indd ii

3/26/11 7:42:17 PM


Dear Reader,
Thank you for choosing LPIC-2: Linux Professional Institute Certification Study Guide.
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
comments 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 If
you think you’ve found a technical error in this book, please visit thelp
.com. Customer feedback is critical to our efforts at Sybex.
Best regards,

Neil Edde
Vice President and Publisher
Sybex, an Imprint of Wiley

FFIRS.indd iii

3/26/11 7:42:18 PM


Acknowledgments
Although this book bears my name as author, many other people contributed to its
creation. Without their help, this book wouldn’t exist, or at best would exist in a lesser
form. Jeff Kellum was the acquisitions editor and so helped get the book started. Jennifer
Leland, the development editor, and Liz Britten, the production editor, oversaw the book
as it progressed through all its stages. Ralph Bonnell was the technical editor, who checked
the text for technical errors and omissions —but any mistakes that remain are my own.
Kim Wimpsett, the copy editor, helped keep the text grammatical and understandable.
The proofreader, Jen Larsen, and technical proofreader, Don Corbet, checked the text for
typos. I’d also like to thank Neil Salkind and others at Studio B, who helped connect me
with Wiley to write this book.

FFIRS.indd iv


3/26/11 7:42:18 PM


About the Author
Roderick W. Smith, LPIC -2, LPIC -1, CompTIA Linux+, is a Linux consultant, author,
and open source programmer. He is the author of over twenty books on Linux and other
open source technologies, including LPIC -1 Study Guide, 2nd Edition, Linux+ Complete
Study Guide, and Linux Administrator Street Smarts, all from Sybex.

FFIRS.indd v

3/26/11 7:42:19 PM


FFIRS.indd vi

3/26/11 7:42:19 PM


Contents at a Glance
Introduction

xix

Assessment Test

Part I

The LPI 201 Exam (60 Weights)


1

Chapter 1

System Startup and Advanced System Management

3

Chapter 2

Linux Kernel Configuration

45

Chapter 3

Basic Filesystem Management

89

Chapter 4

Advanced Disk Management

143

Chapter 5

Networking Configuration


205

Chapter 6

DNS Server Configuration

259

Part II

The LPI 202 Exam (60 Weights)

Chapter 7

Advanced Network Configuration

297

Chapter 8

Configuring File Servers

357

Chapter 9

Configuring Web and Email Servers

405


Chapter 10

Security

469

Chapter 11

System Troubleshooting I: Boot and Kernel Problems

511

Chapter 12

System Troubleshooting II: System Resources
and the User Environment

563

About the Companion CD

609

Appendix

FFIRS.indd vii

xxviii


295

Glossary

615

Index

637

3/26/11 7:42:19 PM


FFIRS.indd viii

3/26/11 7:42:19 PM


Contents
Introduction

xix

Assessment Test

Part I
Chapter

Chapter


TOC.indd ix

1

2

xxviii

The LPI 201 Exam (60 Weights)

1

System Startup and Advanced System
Management

3

Exploring the Boot Process
Booting Linux
Configuring GRUB
Configuring GRUB 2
Installing the GRUB Boot Loader
Interacting with GRUB at Boot Time
Customizing System Startup
Understanding Runlevels
Configuring SysV Startup Scripts
Configuring Upstart
Checking Your Runlevel
Changing Runlevels on a Running System
Compile and Install Programs from Source

Understanding Source Code Issues
Preparing Source Code
Compiling Software
Installing Software
Uninstalling or Upgrading Software
Notify Users of System-Related Issues
Setting Login Messages
Sending Users Messages in Real Time
Summary
Exam Essentials
Review Questions
Answers to Review Questions

4
6
6
9
11
11
12
13
14
19
20
21
23
23
24
26
29

30
32
33
34
35
35
37
41

Linux Kernel Configuration

45

Understanding the Kernel
Obtaining and Installing a Kernel
Reading Kernel Documentation
Locating Kernel Binaries

46
46
48
49

3/26/11 4:49:26 PM


x

Contents


Chapter

3

Preparing a Kernel
Applying Kernel Patches
Configuring the Kernel Source
Compiling a Kernel
Building a Kernel
Installing a Kernel Binary
Installing Kernel Modules
Preparing an Initial RAM Disk
Preparing a Kernel Package
Adding a Kernel to GRUB
Managing Kernel Modules at Runtime
Obtaining Information About the Kernel and Its Modules
Loading Kernel Modules
Removing Kernel Modules
Maintaining Kernel Modules
Summary
Exam Essentials
Review Questions
Answers to Review Questions

50
50
51
59
59
60

61
62
64
65
68
68
72
74
77
79
79
81
85

Basic Filesystem Management

89

Making Filesystems Available
Identifying Filesystem Types
Mounting a Filesystem Once
Permanently Mounting Filesystems
Using an Automounter
Determining What Is Mounted
Unmounting a Filesystem
Maintaining Filesystems
Creating Filesystems
Checking Filesystems for Errors
Tuning Filesystems
Manipulating Swap Space

Managing Optical Discs
Linux Optical Disc Tools
A Linux Optical Disc Example
Creating Cross-Platform Discs
Reading and Writing UDF Discs
Managing Devices with udev
Understanding udev
Preparing to Create udev Rules
Creating udev Rules
Monitoring udev Activity

TOC.indd x

90
91
94
98
101
105
105
107
107
110
111
118
120
121
121
122
124

124
125
127
130
131

3/26/11 4:49:26 PM


Contents

Summary
Exam Essentials
Review Questions
Answers to Review Questions
Chapter

Chapter

4

5

132
133
135
140

Advanced Disk Management


143

Partitioning Disks
Understanding Partitions
Creating Partitions
Configuring RAID
Understanding RAID
Preparing a Disk for Software RAID
Assembling a RAID Array
Using a RAID Array
Configuring Logical Volume Manager
Understanding Logical Volume Manager
Creating and Manipulating Physical Volumes
Creating and Manipulating Volume Groups
Creating and Manipulating Logical Volumes
Using LVM Snapshots
Tuning Disk Access
Understanding Disk Hardware
Identifying Disk Resource Use
Testing Disk Performance
Adjusting Disk Parameters
Monitoring a Disk for Failure
Backing Up and Restoring a Computer
Choosing Backup Hardware
Choosing Backup Software
Planning a Backup Schedule
Preparing for Disaster: Backup Recovery
Summary
Exam Essentials
Review Questions

Answers to Review Questions

144
144
146
148
148
151
152
155
157
157
159
162
164
169
170
171
173
175
176
177
179
179
181
191
192
194
195
197

202

Networking Configuration
Performing Basic Network Configuration
Connecting to a Wireless Network
Connecting to a Network with DHCP
Connecting to a Network with a Static IP Address

TOC.indd xi

xi

205
206
206
211
212

3/26/11 4:49:26 PM


xii

Chapter

Contents

6

Using GUI Configuration Tools

Using the ifup and ifdown Commands
Configuring Hostnames
Checking Basic Connectivity
Setting Additional Network Options
Setting Advanced Router Options
Using an All-In-One Networking Tool
Configuring a VPN
Monitoring Network Traffic
Troubleshooting Network Issues
Identifying Problem Spots
Resolving Hostname Problems
Resolving Connectivity Issues
Resolving Routing Problems
Resolving Security Problems
Summary
Exam Essentials
Review Questions
Answers to Review Questions

216
216
217
218
220
221
225
226
231
238
238

244
246
247
247
248
249
251
255

DNS Server Configuration

259

Understanding the Role of DNS
Running a Caching-Only Name Server
Modifying the Main BIND Configuration File
Modifying Zone Files
Updating from Older BIND Versions
Checking Changes
Creating and Maintaining DNS Zones
Adding New Zones
Configuring Zone Files
Testing Your Configuration
Running a Slave Server
Configuring a Slave Server
Securing Zone Transfers
Making Additional Security Improvements
Running BIND in a Jail
Configuring Split DNS
Summary

Exam Essentials
Review Questions
Answers to Review Questions

TOC.indd xii

260
263
264
266
267
267
268
269
270
274
280
280
281
282
282
283
284
284
286
291

3/26/11 4:49:27 PM



Contents

Part II
Chapter

Chapter

7

8

The LPI 202 Exam (60 Weights)

295

Advanced Network Configuration

297

Configuring a DHCP Server
When to Use DHCP
Basic DHCP Installation
Setting Network-Wide Options
Configuring Delivery of Dynamic Addresses
Configuring Delivery of Fixed Addresses
Configuring a DHCP Relay Agent
Managing LDAP Accounts
What Does LDAP Do?
Preparing a System to Use LDAP Tools
Working with LDIF Files

Adding Accounts
Modifying Accounts
Deleting Accounts
Querying a Server About Accounts
Configuring a Router
Understanding Types of Routing
Activating Routing
Configuring Firewall Rules
Configuring NAT
Automatic Routing Configuration
Configuring SSH
SSH Basics
Setting SSH Options for Your System
SSH Security Considerations
Summary
Exam Essentials
Review Questions
Answers to Review Questions

298
299
300
302
305
306
309
310
310
311
311

314
315
317
317
319
319
320
320
330
331
334
334
336
344
345
346
348
353

Configuring File Servers

357

Understanding the Role of a File Server
Configuring a Samba Server
Setting Global Samba Options
Configuring File Shares
Configuring Printer Shares
Checking Your Configuration and Running Samba
Checking Samba Log Files

Using Linux as an SMB/CIFS Client

TOC.indd xiii

xiii

358
360
360
366
368
370
372
372

3/26/11 4:49:27 PM


xiv

Contents

Configuring an NFS Server
Setting NFS Prerequisites
Setting Basic Export Options
Managing Exports on the Fly
Improving NFS Security
Using Linux as an NFS Client
Configuring an FTP Server
Selecting an FTP Server

Understanding FTP Basics
Configuring Pure-FTPd
Configuring vsftpd
Summary
Exam Essentials
Review Questions
Answers to Review Questions
Chapter

9

Configuring Web and Email Servers
Understanding Web Servers
Setting Basic Apache Options
Configuring Apache to Host Your Site
Setting the Apache User and Group
Changing Web Page Locations
Serving Virtual Domains
Configuring Scripts
Enabling Encryption
Limiting Access to Apache
Controlling Apache
Using apache2ctl
Managing Apache Log Files
Implementing a Proxy Server
Selecting a Proxy Server
Configuring Squid
Adjusting Access Rules
Configuring Clients to Use a Proxy Server
Understanding Email

Configuring a Push Mail Server
Configuring a Domain to Accept Mail
Choosing an Email Server
Running Sendmail
Running Postfix
Managing Email
Checking Log Files

TOC.indd xiv

377
377
379
382
388
388
390
391
392
393
394
396
396
398
402
405
406
407
409
410

411
414
416
418
421
423
424
426
427
427
428
429
430
431
433
433
434
435
440
444
447

3/26/11 4:49:27 PM


Contents

Configuring Procmail
Understanding Mail Storage Formats
Writing Procmail Rules

Seeing Procmail in Action
Configuring POP and IMAP Servers
Selecting a POP or IMAP Server
Configuring Courier
Configuring Dovecot
Summary
Exam Essentials
Review Questions
Answers to Review Questions
Chapter

Chapter

TOC.indd xv

10

11

Security

xv

448
448
449
451
453
453
456

457
458
459
461
465
469

Authenticating Users with PAM
Understanding PAM Principles
Editing a PAM Stack
Examining Example Configurations
Adjusting the Name Service Switch
Enabling TCP Wrappers
Understanding TCP Wrappers Principles
Restricting Access with TCP Wrappers
Calling TCP Wrappers
Using Similar Functionality in Other Programs
Dealing with Ports and Packets
Scanning for and Dealing with Open Ports
Monitoring Network Traffic
Keeping Up-to-Date with Security Issues
Summary
Exam Essentials
Review Questions
Answers to Review Questions

470
471
472
478

480
481
482
483
485
487
489
490
492
497
499
500
502
506

System Troubleshooting I: Boot and
Kernel Problems

511

Approaching a Problem
Troubleshooting Boot Problems
Initializing Hardware
Identifying Your Boot Loader
Locating Boot Loader Files and Code
Interpreting Boot Loader Error Messages
Dealing with Initial RAM Disk Issues
Fixing Problems Early in the OS Boot Stage

512

513
514
514
516
519
523
524

3/26/11 4:49:28 PM


Contents

xvi

Troubleshooting Miscellaneous Problems
Interpreting Boot-Time Displays
Checking the Kernel Ring Buffer
Identifying Hardware
Identifying Loaded Kernel Modules
Checking Log Files
Tracing Software Problems
Summary
Exam Essentials
Review Questions
Answers to Review Questions
Chapter

12


System Troubleshooting II: System Resources
and the User Environment
Troubleshooting System Initialization
Managing the Initialization Process
Dealing with Local Startup Scripts
Managing Login Processes
Adjusting Kernel Options
Fixing Account Problems
Dealing with Password Problems
Adjusting User Shells
Fixing User/Group Association Issues
Adjusting UIDs and GIDs
Adjusting Login Variables
Troubleshooting Shells
Investigating bash Login Scripts
Using Unusual Shells
Investigating Running Processes
Finding Running Processes
Checking Logging Options
Dealing with Library Issues
Dealing with Scheduled Processes
Managing Scheduled Processes
Investigating Problems
Summary
Exam Essentials
Review Questions
Answers to Review Questions

Appendix
Glossary

Index

TOC.indd xvi

About the Companion CD

524
525
525
530
539
542
548
552
553
555
559

563
564
564
568
569
572
574
574
576
576
577
579

579
579
581
582
582
585
590
592
593
596
597
597
600
604
609
615
637

3/26/11 4:49:28 PM


Table of Exercises

TOC.indd xvii

Exercise

2.1

Managing Kernel Modules. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76


Exercise

3.1

Creating Filesystems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109

Exercise

4.1

Creating and Using an LVM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168

Exercise

5.1

Configuring a Network Connection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219

Exercise

7.1

Configuring Logins Without Passwords . . . . . . . . . . . . . . . . . . . . . . . . . . 340

Exercise

8.1

Managing an NFS Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 386


Exercise

9.1

Configuring Apache . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 424

Exercise

10.1

Using Fail2Ban. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 496

Exercise

11.1

Identifying Your Own Hardware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 538

Exercise

12.1 Changing an Account’s UID Value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 577

3/26/11 4:49:28 PM


FLAST.indd xviii

3/26/11 4:53:57 PM




×