Table Of ContentCompTIA
Linux+™
Study Guide
Roderick W. Smith
03843ffirs.indd 3 8/24/09 7:22:26 AM
Acquisitions Editor: Jeff Kellum
Development Editor: Stephanie Barton
Technical Editors: Elizabeth Zinkann, Beau Sanders
Production Editor: Elizabeth 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 Associate Project Manager: Laura Moss-Hollister
Media Associate Producers: Marilynn Hummel, Shawn Patrick
Media Quality Assurance: Josh Frank
Book Designers: Judy Fung, Bill Gibson
Compositor: Craig Woods, Happenstance Type-O-Rama
Proofreader: Jen Larsen, Word One New York
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-50384-3
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 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 disap-
peared 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 Cus-
tomer 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.
CompTIA Linux+ study guide / Roderick W. Smith. — 1st ed.
p. cm.
ISBN 978-0-470-50384-3 (paper/cd-rom)
1. Electronic data processing personnel—Certification. 2. Operating systems (Computers)—Examinations—Study
guides. 3. Computer networks—Examinations—Study guides. 4. Linux. I. Title.
QA76.3.S4765 2009
005.4’32—dc22
2009027779
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 per-
mission. CompTIA Linux+ is a trademark of the Computing Technology Industry Association. All other trademarks
are the property of their respective owners. Wiley Publishing, Inc., is not associated with any product or vendor men-
tioned in this book.
10 9 8 7 6 5 4 3 2 1
03843ffirs.indd 4 8/24/09 7:22:26 AM
Contents
Introduction xix
Assessment Test xxix
Chapter 1 Getting Started with Linux 1
Selecting an Installation Method 2
Choosing a Distribution 2
Selecting an Installation Medium 3
Interacting with the Installer 5
Performing the Installation 5
Configuring Boot Loaders 7
The Role of the Boot Loader 7
Available Boot Loaders 8
Configuring GRUB 9
Troubleshooting Boot Problems 14
Setting Kernel Options in GRUB 14
Using Rescue Discs 15
Resetting the root Password 16
Examining Boot Messages with dmesg 16
Configuring X 17
Selecting an X Server 17
Setting Up X 20
Managing GUI Logins 25
Using Window Managers and Desktop Environments 29
Using Terminal Programs 29
Managing Hardware 30
Finding Compatible Hardware 30
Identifying Hardware in Linux 31
Managing Kernel Modules 35
Summary 38
Exam Essentials 38
Review Questions 40
Answers to Review Questions 44
Chapter 2 Using Text-Mode Commands 47
Using a Command Shell 48
Starting a Shell 49
Using Virtual Terminals 50
Launching Programs 50
Using Shell Shortcuts 51
Using the Shell’s History 52
03843ftoc.indd 11 8/22/09 3:24:34 PM
xii Contents
Manipulating Files and Directories 53
Navigating the Linux Filesystem 54
Manipulating Files 58
Manipulating Directories 62
Locating Files 63
Examining Files’ Contents 66
Using Redirection and Pipes 69
Generating Command Lines 70
Using Device Files 71
Using File Permissions 72
Understanding Accounts and Ownership 72
Using File Access Permissions 72
Changing File Ownership and Permissions 78
Setting Default Permissions 82
Using ACLs 83
Setting Environment Variables 84
Where to Set Environment Variables 85
The Meanings of Common Environment Variables 86
Using Shell Scripts 89
Getting Help 91
Using Man Pages 91
Using Info Pages 94
Using Miscellaneous Program Documentation 95
Using Internet-Based Help Resources 96
Summary 97
Exam Essentials 98
Review Questions 99
Answers to Review Questions 103
Chapter 3 Managing Processes and Editing Files 107
Managing Processes 108
Understanding Processes 108
Examining Process Lists with ps 109
Restricting Processes’ CPU Use 116
Killing Processes 117
Controlling Foreground and Background Processes 119
Monitoring System Statistics 119
Setting Process Permissions 123
Understanding the Risks of SUID and SGID Programs 123
Knowing When to Use SUID or SGID 123
Finding SUID or SGID Programs 124
Running Jobs at Specific Times 125
Understanding the Role of Cron 125
Creating System Cron Jobs 126
Creating User Cron Jobs 127
Using at 128
03843ftoc.indd 12 8/22/09 3:24:34 PM
Contents xiii
Getting and Setting Kernel Information 129
Obtaining Kernel Version Information 129
Setting System Control Data 131
Editing Files with Vi 133
Using Vi Modes 134
Editing Text 134
Saving Changes 137
Summary 138
Exam Essentials 138
Review Questions 139
Answers to Review Questions 143
Chapter 4 Managing System Services 147
Starting and Stopping Services 148
Methods of Starting and Stopping Services 149
Starting and Stopping via SysV Scripts 149
Using Super Servers 153
Using Custom Startup Files 158
Setting the Runlevel 159
Understanding the Role of the Runlevel 159
Using init or telinit to Change the Runlevel 160
Permanently Changing the Runlevel 162
Configuring Log Files 163
Understanding syslogd 163
Setting Logging Options 164
Rotating Log Files 166
Using a Remote Server for Log Files 169
Using Log Files 170
Which Log Files Are Important? 170
Using Log Files to Identify Problems 171
Using Tools to Help Scan Log Files 172
Summary 178
Exam Essentials 178
Review Questions 180
Answers to Review Questions 184
Chapter 5 Managing Users 187
Understanding Multiuser Concepts 188
User Accounts: The Core of a Multiuser System 188
Linking Users Together for Productivity via Groups 193
Mapping UIDs and GIDs to Users and Groups 194
Understanding Home Directories 196
Configuring User Accounts 197
Adding Users 197
Modifying User Accounts 200
03843ftoc.indd 13 8/22/09 3:24:34 PM
xiv Contents
Deleting Accounts 207
Verifying Account Use 208
Configuring Groups 212
Adding Groups 212
Modifying Group Information 213
Deleting Groups 216
Using Common User and Group Strategies 216
Using User Private Groups 217
Using Project Groups 217
Assigning Users to Multiple Groups 218
Improving Account Security 219
Enforcing User Password Security 219
Steps for Reducing the Risk of Compromised Passwords 221
Disabling Unused Accounts 222
Using Shadow Passwords 223
Controlling System Access 224
Accessing Common Servers 224
Controlling root Access 225
Summary 227
Exam Essentials 227
Review Questions 229
Answers to Review Questions 233
Chapter 6 Managing Disks 237
Storage Hardware Identification 238
Types of Storage Devices 239
Linux Storage Hardware Configuration 240
Planning Disk Partitioning 242
Understanding Partitioning Systems 242
Linux Partition Requirements 244
Common Optional Partitions 245
Linux Filesystem Options 248
Partitioning Tools 250
Partition Management and Maintenance 251
Creating Partitions 251
Creating New Filesystems 256
Checking a Filesystem for Errors 258
Adding Swap Space 259
Setting Filesystem Quotas 263
Partition Control 265
Identifying Partitions 265
Mounting and Unmounting Partitions 266
Using Network Filesystems 271
Using df 273
03843ftoc.indd 14 8/22/09 3:24:35 PM
Contents xv
Defining Standard Filesystems 274
Using RAID 276
Using LVM 280
Summary 282
Exam Essentials 283
Review Questions 285
Answers to Review Questions 289
Chapter 7 Managing Packages and System Backups 293
Understanding Package Concepts 294
File Collections 294
The Installed File Database 295
Using Network Repositories 296
Rebuilding Packages 297
Installing and Removing Packages 298
Handling RPM Packages 298
Handling Debian Packages 307
Handling Tarballs 314
Compiling Source Code 318
Managing Package Dependencies and Conflicts 322
Real and Imagined Package Dependency Problems 322
Workarounds to Package Dependency Problems 323
Backing Up and Restoring a Computer 324
Common Backup Hardware 324
Common Backup Programs 326
Performing Network Backups with rsync 333
Planning a Backup Schedule 334
Preparing for Disaster: Backup Recovery 335
Writing to Optical Discs 336
Linux Optical Disc Tools 336
A Linux Optical Disc Example 337
Creating Cross-Platform Discs 338
Summary 339
Exam Essentials 340
Review Questions 341
Answers to Review Questions 345
Chapter 8 Configuring Basic Networking 349
Understanding Networks 350
Basic Functions of Network Hardware 350
Types of Network Hardware 351
Network Packets 353
Network Protocol Stacks 354
03843ftoc.indd 15 8/22/09 3:24:35 PM
xvi Contents
Network Addressing 358
Types of Network Addresses 359
Resolving Hostnames 363
Network Ports 364
Basic Network Configuration 365
Network Hardware Configuration 366
Setting Wireless Options 366
DHCP Configuration 368
Static IP Address Configuration 369
Using GUI Configuration Tools 373
Diagnosing Network Problems 375
Examining the ARP Cache 376
Testing Basic Connectivity 377
Tracing a Route 377
Checking Network Status 378
Name Server Troubleshooting 379
Using General Network Tools 380
Summary 382
Exam Essentials 382
Review Questions 384
Answers to Review Questions 388
Chapter 9 Configuring Advanced Networking 391
Routing Between Networks 392
Firewall Configuration 393
Where a Firewall Fits in a Network 394
Linux Firewall Software 395
Common Server Ports 396
Using iptables 398
Managing Remote Logins 405
Setting Up a Remote Access Server 405
Using Text-Mode Logins 406
Generating SSH Keys 408
Using X Programs Remotely 409
Remote GUI Logins 412
Configuring Basic Printing 414
The Linux Printing Architecture 414
Understanding PostScript and Ghostscript 415
Running a Printing System 416
Configuring CUPS 417
Printing to Network Printers 423
Monitoring and Controlling Print Queues 424
Summary 428
Exam Essentials 428
Review Questions 430
Answers to Review Questions 434
03843ftoc.indd 16 8/22/09 3:24:35 PM
Contents xvii
Chapter 10 Configuring Network Servers I 437
Delivering Network Information 438
Delivering IP Addresses with DHCP 438
Delivering Hostnames with DNS 441
Delivering the Time with NTP 448
Authenticating Users on the Network 454
Using E-mail 455
Understanding E-mail Protocols 456
Configuring SMTP Servers 457
Using Aliases and Forwarding E-mail 460
Choosing a POP or IMAP Server 461
Summary 462
Exam Essentials 463
Review Questions 464
Answers to Review Questions 469
Chapter 11 Configuring Network Servers II 473
Delivering Files Over the Network 474
Delivering Files with Samba 474
Delivering Files with NFS 480
Delivering Files with FTP 483
Configuring Web Servers 489
Using Windows Remote Access Tools 496
Using rdesktop 496
Using VNC 497
Deploying MySQL 499
Picking a SQL Package 499
Using MySQL 500
Summary 503
Exam Essentials 503
Review Questions 505
Answers to Review Questions 509
Chapter 12 Securing Linux 513
Sources of Security Vulnerability 514
Physical Access Problems 515
Stolen Passwords 516
Local Program Bugs 516
Server Bugs 517
Denial-of-Service Attacks 518
Encryption Issues 518
The Human Element 519
Authenticating Users 520
Understanding How Linux Authenticates Users 520
Configuring PAM 521
03843ftoc.indd 17 8/22/09 3:24:35 PM
xviii Contents
Using Network Authentication 523
Using Two-Factor Authentication 526
Using GNU Privacy Guard (GPG) 526
Generating and Importing Keys 527
Encrypting and Decrypting Data 528
Signing Messages and Verifying Signatures 529
SELinux 529
Principles of SELinux 529
Configuring SELinux Running Modes 530
Security Auditing 531
Checking for Open Ports 531
Reviewing Accounts 535
Verifying Installed Files and Packages 537
Intrusion Detection 537
Symptoms of Intrusion 537
Using Snort 538
Using PortSentry 540
Using Wireshark 541
Using Tripwire 542
Generating Checksums Manually 543
Using Package Manager Checksums 544
Using chkrootkit 545
Monitoring Log Files 545
Summary 546
Exam Essentials 547
Review Questions 548
Answers to Review Questions 552
Appendix About the Companion CD 555
What You’ll Find on the CD 556
Sybex Test Engine 556
PDF of the Book 556
Adobe Reader 556
Electronic Flashcards 557
System Requirements 557
Using the CD 557
Troubleshooting 558
Customer Care 558
Glossary 559
Index 597
03843ftoc.indd 18 8/22/09 3:24:35 PM