Upload
lytuyen
View
226
Download
11
Embed Size (px)
Citation preview
ALL a IN ONE
LPIC-l/CompTIAt • TM
Lmux+
Certification
EXAM GUIDE
(Exams LPIC-1/LX0-101 & LXO-102)
Robb H. TracyTECHNISCHE
INFORMATIONSBiBLIOTHEK
UNIVER! iVJcGrawHill
BIBUOTHEK
VER
New York • Chicago • San Francisco • Lisbon
London • Madrid • Mexico City • Milan • New Delhi
SanJuan • Seoul • Singapore • Sydney • Toronto
McGraw-Hill is an independent entity from CompTIA® and the Linux Professional Institute (LPI®). This publicationand CD may be used in assisting students to prepare forthe CompTIA Linux+ exams or the LPIC-1 exam from LPI.
Neither CompTIA, nor LPI, nor McGraw-Hill warrant that use of this publication and CD will ensure passing anyexam. CompTIA and CompTIALinux+ are trademarks or registered trademarks of CompTIA in the United States
and/or other countries. LPI is a trademark or registered trademark of the Linux Professional Institute. All other trade¬marks are trademarks of their respective owners.
Acknowledgments xxvii
Introduction xxix
Chapter I Introduction to Linux I
The Role and Function of Linux 2
The Historical Development of Linux 4
Linux Distributions 6
Common Linux Roles 8
Linux as a Desktop 8
Linux as a Server 9
Linux as a Firewall 10
Chapter Review 11
Accelerated Review 11
Questions 12
Answers 15
Chapter 2 Working with the Linux Shell 17
How the Linux Shell Works 18
Linux Shells 19
Managing Shell Configuration Files 21
Using the Shell Prompt 24
Entering Commands at the Shell Prompt 24
Using Command History 28
Using Command Completion 30
Getting Help for Linux Commands 31
Using man Pages 33
Using info 39
Working with Environment Variables 42
What Are Environment Variables? 42
Managing Environment Variables 43
Creating a User-Defined Variable 49
Working with Aliases 50
Using Redirection and Piping 52
Standard bash File Descriptors 52
Redirecting Output and Input for Shell Commands 53
Piping Information 56
Chapter Review 58
Accelerated Review 60
Questions 62
Answers 69
XV
IPIC-l/CompTIA Linux+ Certification All-in-One Exam Guide__
.
xvi
Chapter 3 Using the vi Text Editor 71
The Role and Function of the vi Text Editor 72
Editing Text Files in vi 75
Opening Files in vi 76
vi Modes 77
Working in Insert Mode 79
Working in Command-Line Mode 79
Working in Command Mode 80
Chapter Review 83
Accelerated Review 85
Questions 86
Answers 89
Chapter 4 Managing Linux Files and Directories 91
Linux File Systems and the Filesystem Hierarchy Standard (FHS) . 92
The Role of the Linux File System 92
The Hierarchical Structure ofthe Linux File System 92
Types of Files Used by Linux 99
Finding Files in the Linux File System 101
Using find 101
Using locate 102
Using which 104
Using whereis 104
Using type 104
Managing Directories from the Command Line 106
Navigating the File System 106
Viewing Directory Contents 108
Creating New Directories Ill
Copying, Moving, and Deleting Directories Ill
Managing Files from the Command Line 112
Creating New Files 112
Viewing File Contents 113
Deleting Files 114
Copying and Moving Files 115
Determining the File Type 115
Working with Link Files 116
Finding Content Within Files 118
Chapter Review 121
Accelerated Review 122
Questions 124
Answers 126
Chapter 5 Installing Linux 127
Designing a Linux Installation 128
Conducting a Needs Assessment 130
Selecting a Distribution 133
Contents
xvii
Verifying System Requirements and Hardware
Compatibility 135
Planning the File System 139
Selecting Software Packages 146
Specify User Accounts 147
Gathering Network Information 148
Selecting an Installation Source 149
Installing Linux 156
Configuring Locale Settings 163
Configuring Time Zone Settings 166
How Time Works on Linux 166
Configuring the Time Zone 168
Chapter Review 169
Accelerated Review 171
Questions 174
Answers 179
Chapter 6 Managing the Linux Boot Process 181
The Linux Boot Process 181
The BIOS Phase 183
The Bootloader Phase 184
The Kernel Phase 185
Configuring the Bootloader 187
Configuring LILO 188
Configuring GRUB 192
Managing Linux Runlevels 203
How Runlevels Work 203
Managing Runlevels and init Scripts 206
Shutting Down the System 217
Chapter Review 218
Accelerated Review 221
Questions 223
Answers 227
Chapter 7 Managing the Graphical Environment 229
How the X Environment Works 230
Configuring the X Environment 235
Configuring the X Server 235
Configuring an X Font Server 245
Configuring a Display Manager 248
Trying Out Desktop Environments 248
Configuring a Display Manager 249
Configuring Accessibility 253
Keyboard Accessibility 254
Mouse Accessibility 256
Screen Readers 257
LPIC-1/CompTIA llnux+ Certification All-ln-One Exam Guide_
xviii
Screen Magnifiers 257
Braille Devices 260
High-Contrast, Large-Text Themes 261
Chapter Review 263
Accelerated Review 266
Questions 270
Answers 273
Chapter 8 Managing Linux Software 275
Managing Software with RPM 276
Installing Software with RPM 276
Managing Installed Software with RPM 288
Using yum to Install RPM Packages 295
Installing Software from Source Code 298
Preparing the Installation Files 299
Compiling the Executable 301
Installing the Executable 302
Uninstalling Software Compiled from Source Code 303
Managing Debian Software Packages 304
Debian Package Naming 305
Installing Packages with dpkg 305
Viewing Package Information with apt-cache 308
Installing Packages with apt-get 310
Using aptitude 312
Managing Shared Libraries 313
How Shared Libraries Work 314
Managing Shared Library Dependencies 315
Chapter Review 318
Accelerated Review 320
Questions 322
Answers 327
Chapter 9 Managing Linux Users and Groups 329
Understanding Linux Users and Groups 331
Linux User Accounts 332
Linux Groups 347
Chapter Review 350
Accelerated Review 352
Questions 353
Answers 355
Chapter 10 Managing Linux File Systems 357
Managing Disk Partitions 357
Using fdisk to Manage Disk Partitions 358
Building a File System with mkfs 363
Understanding LVM 367
Contents
xix
Mounting a Partition with mount 368
Maintaining Linux File Systems 371
Mounting Removable Media 381
Working with Floppies 381
Working with Optical Devices 382
Working with USB and FireWire Devices 383
Backing Up Data 384
Selecting a Backup Medium 385
Selecting a Backup Strategy 386
Using Linux Backup Utilities 389
Chapter Review 394
Accelerated Review 396
Questions 398
Answers 401
Chapter I I Managing Ownership, Permissions, and Quotas 403
Managing Ownership 403
How Ownership Works 403
Managing Ownership from the Command Line 404
Managing File and Directory Permissions 407
How Permissions Work 407
Managing Permissions from the
Command Line with chmod 409
Working with Default Permissions 413
Working with Special Permissions 415
Implementing Disk Quotas 417
Chapter Review 422
Accelerated Review 424
Questions 425
Answers 427
Chapter 12 Managing Hardware Under Linux 429
Managing PC Hardware 429
Identifying Mass Storage Devices 430
Working with Removable Hardware Interfaces 441
Managing System Resources 444
Managing Integrated Devices 449
Managing Systems Without External Peripherals 451
Working with Linux Drivers 451
What Exactly Is a Driver Anyway? 452
How Drivers Are Implemented Under Linux 454
Managing Kernel Modules 455
Working with Hotplug and Coldplug Devices 462
Chapter Review 463
Accelerated Review 466
Questions 469
Answers 473
LPIC-l/CompTIA Linux* Certification All-in-One Exam Guide
XX
Chapter 13 Managing Linux Processes 475
How Linux Handles Processes 475
What Exactly Is a Process? 476
The Heredity of Linux Processes 478
Managing Running Processes 482
Starting System Processes 482
Viewing Running Processes 484
Prioritizing Processes 489
Managing Foreground and Background Processes 491
Ending a Running Process 494
Keeping a Process Running After Logout 495
Scheduling Processes 498
Using the at Daemon 498
Using the cron Daemon 501
Chapter Review 506
Accelerated Review 509
Questions 512
Answers 515
Chapter 14 Writing Shell Scripts 517
Working with Shell Scripts 517
The Components of a Shell Script 517
How Shell Scripts Are Executed 518
Creating a Basic Script 520
Displaying Text on the Screen 520
Adding Commands to a Script 520
Reading Input from the User 521
Using Control Structures in Scripts 523
Using if/then Structures 523
Using case Structures 525
Using Looping Structures 527
Processing Text Streams 529
cut 530
expand and unexpand 530
fmt 531
join and paste 532
nl 533
od 533
pr 535
sed and awk 535
sort 539
split 539
tr 540
uniq 540
wc 541
Contents
xxi
Using Command Substitution and Shell Functions 542
Using Command Substitution 542
Using Shell Functions 543
Chapter Review 544
Accelerated Review 548
Questions 549
Answers 553
Chapter 15 Managing Linux Network Settings 555
IP Networking Overview 556
What Is a Protocol? 557
How IP Addresses Work 561
How the Subnet Mask Works 564
Specifying the DNS Server and
Default Gateway Router Addresses 566
Configuring Network Addressing Parameters 568
Installing the Ethernet Board 569
Configuring IP Parameters 570
Configuring Routing Parameters 576
Configuring Name Resolver Settings 578
Troubleshooting Network Problems 581
Using a Standardized Troubleshooting Model 581
Using ping 583
Using netstat 585
Using traceroute 585
Using Name Resolution Tools 587
host 588
Chapter Review 589
Accelerated Review 592
Questions 594
Answers 598
Chapter 16 Managing Network Services on Linux 601
Configuring Printing with CUPS 602
How Linux Printing Works 602
Installing CUPS 604
Configuring CUPS 605
Using the Line Printer Daemon (lpd) 613
Troubleshooting Printing Issues 613
Maintaining System Time 616
Setting the Hardware Clock with hwclock 617
Synchronizing Time with netdate 618
Synchronizing Time with NTP 618
Managing an MTA 625
How E-Mail Works 625
Using MTA Management Commands on Linux 629
LPIC-l/CompTIA Linux* Certification All-in-One Exam Guide
xxii
Managing SQL Data 632
How Databases Work 632
Installing MySQL 633
Managing Data in the SQL Server 635
Chapter Review 638
Accelerated Review 642
Questions 646
Answers 649
Chapter 17 Securing Linux 651
Secure the System 651
Securing the Physical Environment 651
Securing Access to the Operating System 653
Control User Access 655
To root Or Not to root? 655
Implementing a Strong Password Policy 659
Configuring User Limits 661
Disabling User Login 663
Auditing Files 665
Defending Against Network Attacks 668
Mitigating Network Vulnerabilities 668
Implementing a Firewall with iptables 672
Managing System Logs 679
Configuring Log Files 679
Using Log Files to Troubleshoot Problems 684
Using Log Files to Detect Intruders 686
Configuring xinetd and inetd 688
Configuring xinetd 689
Configuring inetd 692
Chapter Review 695
Accelerated Review 700
Questions 704
Answers 707
Chapter 18 Using Encryption 709
How Encryption Works 710
Symmetric Encryption 711
Asymmetric Encryption 712
Encrypting Remote Access with OpenSSH 715
How OpenSSH Works 715
Configuring OpenSSH 717
Tunneling Traffic Through SSH 721
Configuring SSH to Use Public Key Authentication 726
Encrypting Linux Files 730
How GPG Works 730
Using GPG to Encrypt Files 731
XXIII
Chapter Review 737
Accelerated Review 742
Questions 745
Answers 748
AppendixA Exam Objective Reference 751
Exam LXO-101 751
Exam LXO-102 760
Appendix B About the CD 769
System Requirements 769
Accessing the MasterExam Practice
Exams in Linux 769
Installing and Running MasterExam 770
MasterExam 770
Video Training Clips 771
PDF Copy of the Book 771
Help 771
Removing Installation(s) 771
Technical Support 771
LearnKey Technical Support 771
Index 773