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

linux professional institute certification study guide, 2nd edition 2

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 (8 MB, 623 trang )

LPIC-1

Linux Professional
Institute Certification
Study Guide
Second Edition

04836book.indd 1

1/16/09 9:34:31 AM


04836book.indd 2

1/16/09 9:34:32 AM


LPIC-1

Linux Professional
Institute Certification
Study Guide
Second Edition

Roderick W. Smith

04836book.indd 3

1/16/09 9:34:32 AM



Acquisitions Editor: Jeff Kellum
Development Editor: Kim Wimpsett
Technical Editors: Emmett Dulaney and Evan Blomquist
Production Editor: Christine O’Connor
Copy Editor: Tiffany Taylor
Production Manager: Tim Tate
Vice President and Executive Group Publisher: Richard Swadley
Vice President and Publisher: Neil Edde
Assistant Project Manager: Jenny Swisher
Associate Producer: Kit Malone
Quality Assurance: Angie Denny
Book Designer: Judy Fung, Bill Gibson
Compositor: Craig Woods, Happenstance Type-O-Rama
Proofreader: Publication Services, Inc.
Indexer: Ted Laux
Project Coordinator, Cover: Lynsey Stanford
Cover Designer: Ryan Sneed
Copyright © 2009 by Wiley Publishing, Inc., Indianapolis, Indiana
Published simultaneously in Canada
ISBN: 978-0-470-40483-6
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-1 : Linux Professional Institute Certification study guide / Roderick W. Smith. — 2nd ed.
p. cm.
ISBN 978-0-470-40483-6 (pbk. : CD-ROM)
1. Electronic data processing personnel—Certification. 2. Linux—Examinations—Study guides. I. Title.
QA76.3.S4773 2009
005.4’32—dc22
2009042577
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

04836book.indd 4

1/16/09 9:34:33 AM


Dear Reader,
Thank you for choosing LPIC-1: Linux Professional Institute Certification Study Guide,
Second Edition. 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 thirty 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 , or if you think
you’ve found a technical error in this book, please visit . Customer feedback is critical to our efforts at Sybex.


Best regards,






04836book.indd 5

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

1/16/09 9:34:33 AM


04836book.indd 6

1/16/09 9:34:33 AM



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. Kim Wimpsett, the
Development Editor, and Christine O’Connor, the Production Editor, oversaw the book as
it progressed through all its stages. Emmett Dulaney was the Technical Editor, who checked
the text for technical errors and omissions—but any mistakes that remain are my own.
Tiffany Taylor, the copy editor, helped keep the text grammatical and understandable. The
proofreader, Publications Services, Inc., 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.

About the Author
Roderick W. Smith is a Linux consultant and author. He has written over a dozen
books on Linux, FreeBSD, and computer networking, including the Linux+ Study
Guide and Linux Administrator Street Smarts (both from Sybex). He can be reached
at

04836book.indd 7

1/16/09 9:34:33 AM


04836book.indd 8

1/16/09 9:34:33 AM


Contents at a Glance
Introduction


xxi

Assessment Test

04836book.indd 9

xxix

Part I

The LPI 101 Exam (60 Weights)

1

Chapter 1

Exploring Linux Command-Line Tools

3

Chapter 2

Managing Software

Chapter 3

Configuring Hardware

103


Chapter 4

Managing Files

171

Chapter 5

Booting Linux and Editing Files

219

Part II

The LPI 102 Exam (60 Weights)

Chapter 6

Configuring the X Window System, Localization,
and Printing

261

Chapter 7

Administering the System

323


Chapter 8

Configuring Basic Networking

377

Chapter 9

Writing Scripts, Configuring E-Mail, and Using Databases

421

Chapter 10

Securing Your System

469

Appendix A

About the Companion CD

513

43

259

Glossary


517

Index

545

1/16/09 9:34:33 AM


04836book.indd 10

1/16/09 9:34:33 AM


Contents
Introduction

xxi

Assessment Test

Part I
Chapter

Chapter

04836book.indd 11

1


2

xxix

The LPI 101 Exam (60 Weights)

1

Exploring Linux Command-Line Tools

3

Understanding Command-Line Basics
Exploring Your Linux Shell Options
Using a Shell
Exploring Shell Configuration
Using Environment Variables
Getting Help
Using Streams, Redirection, and Pipes
Exploring Types of Streams
Redirecting Input and Output
Piping Data Between Programs
Generating Command Lines
Processing Text Using Filters
File-Combining Commands
File-Transforming Commands
File-Formatting Commands
File-Viewing Commands
File-Summarizing Commands
Using Regular Expressions

Understanding Regular Expressions
Using grep
Using sed
Summary
Exam Essentials
Review Questions
Answers to Review Questions

4
4
5
11
11
12
13
14
14
16
17
17
18
20
23
26
28
29
30
31
32
34

34
36
40

Managing Software

43

Package Concepts
Using RPM
RPM Distributions and Conventions
The rpm Command Set
Extracting Data from RPMs
Using Yum

44
46
46
48
52
53

1/11/09 2:27:22 PM


xii 

Contents

RPM and Yum Configuration Files

RPM Compared to Other Package Formats
Using Debian Packages
Debian Distributions and Conventions
The dpkg Command Set
Using apt-cache
Using apt-get
Using dselect, aptitude, and Synaptic
Reconfiguring Packages
Debian Packages Compared to Other Package Formats
Configuring Debian Package Tools
Converting Between Package Formats
Package Dependencies and Conflicts
Real and Imagined Package Dependency Problems
Workarounds to Package Dependency Problems
Startup Script Problems
Managing Shared Libraries
Library Principles
Locating Library Files
Library Management Commands
Managing Processes
Understanding the Kernel: The First Process
Examining Process Lists
Understanding Foreground and Background Processes
Managing Process Priorities
Killing Processes
Summary
Exam Essentials
Review Questions
Answers to Review Questions
Chapter


3

Configuring Hardware
Configuring the BIOS and Core Hardware
Understanding the Role of the BIOS
IRQs
I/O Addresses
DMA Addresses
Boot Disks and Geometry Settings
Coldplug and Hotplug Devices
Configuring Expansion Cards
Configuring PCI Cards
Learning about Kernel Modules
Loading Kernel Modules
Removing Kernel Modules

04836book.indd 12

57
58
59
59
60
63
63
67
69
69
70

71
72
73
74
76
76
77
78
81
83
83
83
89
90
91
92
93
95
99
103
104
104
107
109
111
111
113
114
115
116

118
119

1/11/09 2:27:22 PM


Contents 

Chapter

04836book.indd 13

4

xiii

Configuring USB Devices
USB Basics
Linux USB Drivers
USB Manager Applications
Configuring Hard Disks
Configuring PATA Disks
Configuring SATA Disks
Configuring SCSI Disks
Configuring External Disks
Designing a Hard Disk Layout
Why Partition?
Types of Disk Partitions
An Alternative to Partitions: LVM
Mount Points

Common Partitions and Filesystem Layouts
Creating Partitions and Filesystems
Partitioning a Disk
Preparing a Partition for Use
Maintaining Filesystem Health
Tuning Filesystems
Maintaining a Journal
Checking Filesystems
Monitoring Disk Use
Mounting and Unmounting Filesystems
Temporarily Mounting or Unmounting Filesystems
Permanently Mounting Filesystems
Summary
Exam Essentials
Review Questions
Answers to Review Questions

120
120
121
122
123
123
124
124
126
126
126
127
130

130
131
132
133
137
143
143
147
148
150
153
153
159
162
162
164
168

Managing Files

171

Managing Files
File Naming and Wildcard Expansion Rules
File Commands
File Archiving Commands
Managing Links
Directory Commands
Managing File Ownership
Assessing File Ownership

Changing a File’s Owner
Changing a File’s Group
Controlling Access to Files
Understanding Permissions
Changing a File’s Mode

172
172
174
179
185
186
187
188
188
189
189
189
194

1/11/09 2:27:22 PM


xiv 

Contents

Chapter

5


PART II
Chapter

Setting the Default Mode and Group
Changing File Attributes
Managing Disk Quotas
Enabling Quota Support
Setting Quotas for Users
Locating Files
The FHS
Tools for Locating Files
Summary
Exam Essentials
Review Questions
Answers to Review Questions

197
199
200
200
201
202
202
206
210
210
212
216


Booting Linux and Editing Files

219

Installing Boot Loaders
Boot Loader Principles
Using LILO as the Boot Loader
Using GRUB as the Boot Loader
Understanding the Boot Process
Extracting Information about the Boot Process
Locating and Interpreting Boot Messages
The Boot Process
Dealing with Runlevels and the Initialization Process
Runlevel Functions
Identifying the Services in a Runlevel
Managing Runlevel Services
Checking Your Runlevel
Changing Runlevels on a Running System
Editing Files with Vi
Understanding Vi Modes
Exploring Basic Text-Editing Procedures
Saving Changes
Summary
Exam Essentials
Review Questions
Answers to Review Questions

220
221
222

227
232
232
233
234
235
235
237
239
241
241
244
245
245
248
249
249
251
255

The LPI 102 Exam (60 Weights)
6

Configuring the X Window System, Localization, and
Printing
261
Configuring Basic X Features
X Server Options for Linux
Methods of Configuring X


04836book.indd 14

259

262
262
263

1/11/09 2:27:22 PM


Contents 

X Configuration Options
Obtaining X Display Information
Configuring X Fonts
Font Technologies and Formats
Configuring X Core Fonts
Configuring a Font Server
Configuring Xft Fonts
Managing GUI Logins
The X GUI Login System
Running an XDMCP Server
Configuring an XDMCP Server
Using X for Remote Access
X Client/Server Principles
Using Remote X Clients
X Accessibility
Keyboard and Mouse Accessibility Issues
Screen Display Settings

Using Additional Assistive Technologies
Configuring Localization and Internationalization
Setting Your Time Zone
Querying and Setting Your Locale
Configuring Printing
Conceptualizing the Linux Printing Architecture
Understanding PostScript and Ghostscript
Running a Printing System
Configuring CUPS
Monitoring and Controlling the Print Queue
Summary
Exam Essentials
Review Questions
Answers to Review Questions
Chapter

7

Administering the System
Managing Users and Groups
Understanding Users and Groups
Configuring User Accounts
Configuring Groups
Tuning User and System Environments
Using System Log Files
Understanding syslogd
Setting Logging Options
Manually Logging Data
Rotating Log Files
Reviewing Log File Contents


04836book.indd 15

xv

267
275
276
276
277
279
280
281
282
283
284
285
286
286
289
289
291
293
293
294
295
299
299
300
302

303
309
312
312
314
319
323
324
324
327
338
342
343
343
344
346
347
350

1/11/09 2:27:23 PM


xvi 

Contents

Maintaining the System Time
Linux Time Concepts
Manually Setting the Time
Using NTP

Running Jobs in the Future
Understanding the Role of cron
Creating System cron Jobs
Creating User cron Jobs
Using at
Summary
Exam Essentials
Review Questions
Answers to Review Questions
Chapter

04836book.indd 16

8

352
352
353
354
360
360
361
362
366
368
368
370
374

Configuring Basic Networking


377

Understanding TCP/IP Networking
Knowing the Basic Functions of Network Hardware
Investigating Types of Network Hardware
Understanding Network Packets
Understanding Network Protocol Stacks
Knowing TCP/IP Protocol Types
Understanding Network Addressing
Using Network Addresses
Resolving Hostnames
Network Ports
Configuring Linux for a Local Network
Network Hardware Configuration
Configuring with DHCP
Configuring with a Static IP Address
Configuring Routing
Using GUI Configuration Tools
Using the ifup and ifdown Commands
Configuring Hostnames
Diagnosing Network Connections
Testing Basic Connectivity
Tracing a Route
Checking Network Status
Examining Raw Network Traffic
Using Additional Tools
Summary
Exam Essentials
Review Questions

Answers to Review Questions

378
378
379
381
381
383
384
385
391
393
396
396
396
398
400
402
402
403
406
406
406
408
408
410
412
412
414
418


1/11/09 2:27:23 PM


Contents 

Chapter

Chapter

9

10

Writing Scripts, Configuring E-mail,
and Using Databases

421

Managing the Shell Environment
Reviewing Environment Variables
Understanding Common Environment Variables
Using Aliases
Modifying Shell Configuration Files
Writing Scripts
Beginning a Shell Script
Using Commands
Using Variables
Using Conditional Expressions
Using Loops

Using Functions
Managing E‑mail
Understanding E‑mail
Choosing E‑mail Software
Managing E‑mail
Securing Your E-mail Server
Managing Data with SQL
Picking a SQL Package
Understanding SQL Basics
Using MySQL
Summary
Exam Essentials
Review Questions
Answers to Review Questions

422
422
423
427
427
429
430
430
432
435
437
438
440
440
442

444
448
449
449
450
451
459
460
462
466

Securing Your System
Administering Network Security
Using Super Server Restrictions
Disabling Unused Servers
Administering Local Security
Securing Passwords
Limiting root Access
Setting Login, Process, and Memory Limits
Locating SUID/SGID Files
Configuring SSH
SSH Basics
Setting SSH Options for Your System
SSH Security Considerations

04836book.indd 17

xvii

469

470
471
477
484
484
488
489
491
493
493
494
501

1/11/09 2:27:23 PM


xviii 

Contents

Appendix

Glossary
Index

04836book.indd 18

A

Using GPG

Generating and Importing Keys
Encrypting and Decrypting Data
Signing Messages and Verifying Signatures
Summary
Exam Essentials
Review Questions
Answers to Review Questions

501
502
503
504
504
505
506
510

About the Companion CD

513

What You’ll Find on the CD
Sybex Test Engine
PDF of the Book
Adobe Reader
Electronic Flashcards
System Requirements
Using the CD
Troubleshooting
Customer Care


514
514
514
514
515
515
515
515
516



517
545

1/11/09 2:27:23 PM


Table of Exercises

04836book.indd 19

Exercise

1.1

Exercise

2.1


Managing Packages Using RPM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55

Exercise

2.2

Managing Debian Packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66

Exercise

3.1

Creating Filesystems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141

Exercise

4.1

Modifying Ownership and Permissions . . . . . . . . . . . . . . . . . . . . . . . . . . 196

Exercise

4.2

Locating Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209

Exercise

5.1


Changing Runlevels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243

Exercise

6.1

Changing the X Resolution and Color Depth . . . . . . . . . . . . . . . . . . . . . . 274

Exercise

7.1

Creating User Accounts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 331

Editing Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

Exercise

7.2

Creating User cron Jobs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 364

Exercise

8.1

Configuring a Network Connection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 403

Exercise


9.1

Changing Your bash Prompt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 426

Exercise

9.2

Creating a Simple Script . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 439

Exercise

9.3

Creating a SQL Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 455

Exercise

10.1 Monitor Network Port Use . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 478

1/16/09 9:35:01 AM


04836book.indd 20

1/16/09 9:35:01 AM




×