Contents
Acknowledgments
About the Author
Table of Exercises
CompTIA Certification
Introduction
The Exam Objectives
Assessment Test
Answers to the Assessment Test
Part I: Exam 1
Chapter 1: Exploring Linux Command-Line Tools
Understanding Command-Line Basics
Using Streams, Redirection, and Pipes
Processing Text Using Filters
Using Regular Expressions
Summary
Exam Essentials
Review Questions
Chapter 2: Managing Software
Package Concepts
Using RPM
Using Debian Packages
Converting Between Package Formats
Package Dependencies and Conflicts
Managing Shared Libraries
Managing Processes
Summary
Exam Essentials
Review Questions
Chapter 3: Configuring Hardware
Configuring the Firmware and Core Hardware
Configuring Expansion Cards
Configuring USB Devices
Configuring Hard Disks
Designing a Hard Disk Layout
Creating Partitions and Filesystems
Maintaining Filesystem Health
Mounting and Unmounting Filesystems
Summary
Exam Essentials
Review Questions
Chapter 4: Managing Files
Using File Management Commands
Managing File Ownership
Controlling Access to Files
Managing Disk Quotas
Locating Files
Summary
Exam Essentials
Review Questions
Chapter 5: Booting Linux and Editing Files
Installing Boot Loaders
Understanding the Boot Process
Dealing with Runlevels and the Initialization Process
Using Alternative Boot Systems
Editing Files with Vi
Summary
Exam Essentials
Review Questions
Part II: Exam 2
Chapter 6: Configuring the X Window System, Localization, and Printing
Configuring Basic X Features
Configuring X Fonts
Managing GUI Logins
Using X for Remote Access
X Accessibility
Configuring Localization and Internationalization
Configuring Printing
Summary
Exam Essentials
Review Questions
Chapter 7: Administering the System
Managing Users and Groups
Tuning User and System Environments
Using System Log Files
Maintaining the System Time
Running Jobs in the Future
Summary
Exam Essentials
Review Questions
Chapter 8: Configuring Basic Networking
Understanding TCP/IP Networking
Understanding Network Addressing
Configuring Linux for a Local Network
Diagnosing Network Connections
Summary
Exam Essentials
Review Questions
Chapter 9: Writing Scripts, Configuring Email, and Using Databases
Managing the Shell Environment
Writing Scripts
Managing Email
Managing Data with SQL
Summary
Exam Essentials
Review Questions
Chapter 10: Securing Your System
Administering Network Security
Administering Local Security
Configuring SSH
Using GPG
Summary
Exam Essentials
Review Questions
Appendix A: Answers to Review Questions
Appendix B: About the Additional Study Tools
Index
Advertisements
CompTIA Certification
In a digital world, digital literacy is an essential survival skill. Certification proves you have the knowledge and skill to solve business problems in virtually any business environment. Certifications are highly valued credentials that qualify you for jobs, increased compensation, and promotion.
CompTIA Linux+ Powered by LPI certification is held by many IT staff members in organizations—25 percent of IT staff within a random sampling of U.S. organizations within a cross section of industry verticals have earned CompTIA Linux+ certification.
CompTIA Linux+ Powered by LPI Validates the fundamental knowledge and skills required of junior Linux administrators. The exams cover system architecture, GNU and UNIX commands, user interfaces and desktops, and Linux installation and package management.
Candidate Job Roles Includes junior Linux administrator, junior network administrator, systems administrator, Linux database administrator, and web administrator.
Dual Certification If you choose, certification in CompTIA Linux+ Powered by LPI, attained by passing CompTIA exams LX0-101 and LX0-102, enables you to become certified in LPIC-1 as well.
Starting Salary The average salary for CompTIA Linux+ Powered by LPI certification holders is $76,000 (USD).
Mandated/Recommended by Organizations Worldwide Companies such as Dell, HP, IBM, Lenovo, and Xerox recommend or require CompTIA Linux+ Certification.
CompTIA offers a number of credentials that form a foundation for your career in technology and allow you to pursue specific areas of concentration. Depending on the path you choose to take, CompTIA certifications help you build upon your skills and knowledge, supporting learning throughout your entire career.
Four Steps to Getting Certified and Staying Certified
1. Review the exam objectives. | Review the certification objectives to make sure you know what is covered on the exam: http://www.comptia.org/certifications/testprep/examobjectives.aspx. |
2. Practice for the exam. | After you have studied for the certification, take a free assessment and sample test to get an idea what type of questions might be on the exam: http://www.comptia.org/certifications/testprep/practicetests.aspx. |
3. Purchase an exam voucher. | Purchase exam vouchers on the CompTIA Marketplace, which is located at http://www.comptiastore.com. |
4. Take the test! | Select a certification exam provider and schedule a time to take your exam. You can find exam providers here: http://www.comptia.org/certifications/testprep/testingcenters.aspx. |
The free IT Pro online community (http://itpro.comptia.org) provides valuable content to students and professionals.
This courseware bears the seal of CompTIA Approved Quality Content. This seal signifies this content covers 100 percent of the exam objectives and implements important instructional design principles. CompTIA recommends multiple learning tools to help increase coverage of the learning objectives.
Global Recognition CompTIA is recognized globally as the leading IT nonprofit trade association and has enormous credibility. Plus, CompTIA’s certifications are vendor-neutral and offer proof of foundational knowledge that translates across technologies.
Valued by Hiring Managers Hiring managers value CompTIA certification because it is a vendor- and technology-independent validation of your technical skills.
Recommended or Required by Government and Businesses Many government organizations and corporations either recommend or require technical staff to be CompTIA certified (for example, Dell, Sharp, Ricoh, the U.S. Department of Defense, and many more).
Three CompTIA Certifications Ranked in the Top 10 In a study by DICE of 17,000 technology professionals, certifications helped command higher salaries at all experience levels.
Visit CompTIA online Visit http://www.comptia.org to learn more about getting CompTIA certified.
Contact CompTIA Call 866-835-8020 ext. 5 or email questions@comptia.org.
Join the IT Pro Community Visit http://itpro.comptia.org to join the IT Pro community to get relevant career information.
Connect with Us Learn more about us via LinkedIn, Facebook, Twitter, Flickr, and YouTube.
Table of Exercises
Exercise 1.1 | Editing Commands |
Exercise 2.1 | Managing Packages Using RPM |
Exercise 2.2 | Managing Debian Packages |
Exercise 3.1 | Creating Filesystems |
Exercise 4.1 | Modifying Ownership and Permissions |
Exercise 4.2 | Locating Files |
Exercise 5.1 | Changing Runlevels |
Exercise 6.1 | Printing with Linux |
Exercise 7.1 | Creating User Accounts |
Exercise 7.2 | Creating User cron Jobs |
Exercise 8.1 | Practice Resolving Hostnames |
Exercise 8.2 | Configuring a Network Connection |
Exercise 9.1 | Changing Your bash Prompt |
Exercise 9.2 | Creating a Simple Script |
Exercise 9.3 | Creating a SQL Database |
Exercise 10.1 | Monitor Network Port Use |
Senior Acquisitions Editor: Jeff Kellum
Development Editor: Alexa Murphy
Technical Editors: Ross Brunson and Kevin Glendenning, FOSSter.com
Production Editor: Eric Charbonneau
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: Marilyn Hummel
Media Quality Assurance: Josh Frank
Book Designer: Judy Fung
Proofreader: Candace Cunningham
Indexer: Ted Laux
Project Coordinator, Cover: Katherine Crocker
Cover Designer: Ryan Sneed
Copyright © 2013 by John Wiley & Sons, Inc., Indianapolis, Indiana
Published simultaneously in Canada
ISBN: 978-1-118-53174-7
ISBN: 978-1-118-61130-2 (ebk.)
ISBN: 978-1-118-57034-0 (ebk.)
ISBN: 978-1-118-57048-7 (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 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 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: 2012951868
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. CompTIA and Linux + are trademarks or registered trademarks of Computing Technology Industry Association, Inc. 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.
Dear Reader,
Thank you for choosing CompTIA Linux+ 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 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 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
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. Alexa Murphy, the developmental editor, and Eric Charbonneau, the production editor, oversaw the book as it progressed through all its stages. Ross Brunson and Kevin Glendenning were the technical editors 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, Candace Cunningham, 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 more than 20 books on Linux, FreeBSD, and computer networking, including Linux Essentials, the LPIC-2 Study Guide, and Linux Administrator Street Smarts (all from Sybex). He can be reached at rodsmith@rodsbooks.com.
Introduction
Why should you learn about Linux? It’s a fast-growing operating system, and it is inexpensive and flexible. Linux is also a major player in the small and mid-sized server field, and it’s an increasingly viable platform for workstation and desktop use as well. By understanding Linux, you’ll increase your standing in the job market. Even if you already know Windows or Mac OS and your employer uses these systems exclusively, understanding Linux will give you an edge when you’re looking for a new job or you’re looking for a promotion. For instance, this knowledge will help you to make an informed decision about if and when you should deploy Linux. The Computing Technology Industry Association (CompTIA) promotes the Linux+ exam as an introductory certification for people who want to enter careers involving Linux. The exam is meant to certify that an individual has the skills necessary to install, operate, and troubleshoot a Linux system and is familiar with Linux-specific concepts and basic hardware.
The purpose of this book is to help you pass the Linux+ exams (LX0-101 and LX0-102) updated in 2012. Because these exams cover basic Linux installation, configuration, maintenance, applications, networking, and security, those are the topics that are emphasized in this book. You’ll learn enough to get a Linux system up and running and to configure it for many common tasks. Even after you’ve taken and passed the Linux+ exams, this book should remain a useful reference.
Linux is a clone of the Unix operating system (OS) that has been popular in academia and many business environments for years. Formerly used exclusively on large mainframes, Unix and Linux can now run on small computers—which are actually far more powerful than the mainframes of just a few years ago. Because of its mainframe heritage, Unix (and hence also Linux) scales well to perform today’s demanding scientific, engineering, and network server tasks.
Linux consists of a kernel, which is the core control software, and many libraries and utilities that rely on the kernel to provide features with which users interact. The OS is available in many different distributions, which are collections of a specific kernel with specific support programs.
Several good reasons to get your Linux certification exist. There are four major benefits:
Relevance The exams were designed with the needs of Linux professionals in mind. This was done by performing surveys of Linux administrators to learn what they actually need to know to do their jobs.
Quality The exams have been extensively tested and validated using psychometric standards. The result is an ability to discriminate between competent administrators and those who must still learn more material.
Neutrality CompTIA is an organization that doesn’t itself market any Linux distribution. This fact removes the motivation to create an exam that’s designed as a way to market a particular distribution.
Support The exams are supported by major players in the Linux world.
The certification is available to anyone who passes the two required exams: LX0-101 and LX0-102. You don’t have to work for a particular company. It’s not a secret society.
The exam is administered by Pearson VUE. The exam can be taken at any Pearson VUE testing center. If you pass, you will get a certificate in the mail saying that you have passed. Contact (877) 551-PLUS (551-7587) for Pearson VUE contact information.
To register for the exam with Pearson VUE, call (877) 551-PLUS (551-7587), or register online at www.vue.com/comptia. However you do it, you’ll be asked for your name, mailing address, phone number, employer, when and where you want to take the test (i.e., which testing center), and your credit card number (arrangement for payment must be made at the time of registration).
Anybody who wants to pass the certification exams may benefit from this book. This book covers the material that someone new to Linux will need to learn the OS from the beginning, and it continues to provide the knowledge you need up to a proficiency level sufficient to pass the two exams. You can pick up this book and learn from it even if you’ve never used Linux before, although you’ll find it an easier read if you’ve at least casually used Linux for a few days. If you’re already familiar with Linux, this book can serve as a review and as a refresher course for information with which you might not be completely familiar. In either case, reading this book will help you to pass the exams.
This book is written with the assumption that you know at least a little bit about Linux (what it is, and possibly a few Linux commands). I also assume you know some basics about computers in general, such as how to use a keyboard, how to insert a disc into an optical drive, and so on. Chances are, you have used computers in a substantial way in the past—perhaps even Linux, as an ordinary user, or maybe you have used Windows or Mac OS. I do not assume that you have extensive knowledge of Linux system administration, but if you’ve done some system administration, you can still use this book to fill in gaps in your knowledge.
This book consists of 10 chapters plus supplementary information: an online glossary, this introduction, and the assessment test after the introduction. The chapters are organized as follows:
Chapters 1 through 5 cover the LX0-101 exam, while Chapters 6 through 10 cover the LX0-102 exam. These make up Part I and Part II of the book, respectively.
Each chapter begins with a list of the exam objectives that are covered in that chapter. The book doesn’t cover the objectives in order. Thus, you shouldn’t be alarmed at some of the odd ordering of the objectives within the book. At the end of each chapter, you’ll find a couple of elements you can use to prepare for the exam:
Exam Essentials This section summarizes important information that was covered in the chapter. You should be able to perform each of the tasks or convey the information requested.
Review Questions Each chapter concludes with 20 review questions. You should answer these questions and check your answers against the ones provided after the questions. If you can’t answer at least 80 percent of these questions correctly, go back and review the chapter, or at least those sections that seem to be giving you difficulty.
To get the most out of this book, you should read each chapter from start to finish and then check your memory and understanding with the chapter-end elements. Even if you’re already familiar with a topic, you should skim the chapter; Linux is complex enough that there are often multiple ways to accomplish a task, so you may learn something even if you’re already competent in an area.
Readers of this book can access a Web site that contains several additional study tools, including the following:
Sample Tests All of the questions in this book will be included, including the Assessment Test at the end of this introduction and the 200 from the review sections at the end of each chapter. In addition, there are two 50-question bonus exams. The test engine runs on Windows, Linux, and Mac OS.
Electronic Flashcards The additional study tools includes 150 questions in flashcard format (a question followed by a single correct answer). You can use these to review your knowledge of the exam objectives. The flashcards run on both Windows and Linux.
Glossary of Terms as a PDF File In addition, there is a searchable glossary in PDF format, which can be read on all platforms that support PDF.
This book uses certain typographic styles in order to help you quickly identify important information and to avoid confusion over the meaning of words such as on-screen prompts. In particular, look for the following styles
In addition to these text conventions, which can apply to individual words or entire paragraphs, a few conventions highlight segments of text:
The Exam Objectives
Behind every computer industry exam you can be sure to find exam objectives—the broad topics in which exam developers want to ensure your competency. The official exam objectives are listed here. (They’re also printed at the start of the chapters in which they’re covered.)
The following are the areas in which you must be proficient in order to pass the LX0-101 exam. This exam is broken into four topics (101–104), each of which has three to eight objectives. Each objective has an associated weight, which reflects its importance to the exam as a whole. The four main domains are
Domain | % of Exam |
101 System Architecture | 14% |
102 Linux Installation and Package Management | 18% |
103 GNU and Unix Commands | 43% |
104 Devices, Linux Filesystems, Filesystem Hierarchy Standard | 25% |
Total | 100% |
The 102 exam comprises six topics (105–110), each of which contains three or four objectives. The six major topics are weighted as follows:
Domain | % of Exam |
105 Shells, Scripting and Data Management | 17% |
106 User Interfaces and Desktops | 8% |
107 Administrative Tasks | 20% |
108 Essential System Services | 17% |
109 Networking Fundamentals | 23% |
110 Security | 15% |
Total | 100% |
Assessment Test
1. The following line appears in your X server’s mouse configuration area. What can you conclude?
Option "Protocol" "PS/2"
A. The mouse is connected to the PS/2 hardware mouse port.
B. The mouse uses the PS/2 software communication standard.
C. The computer is an ancient IBM PS/2 system.
D. The mouse was designed for use with IBM’s OS/2.
E. A slash (/) is invalid in a protocol name, so the mouse won’t work.
2. How can you tell whether your system is using inetd or xinetd as a super server? (Select two.)
A. Type ps ax | grep inetd, and examine the output for signs of inetd or xinetd.
B. Type superserver to see a report on which super server is running.
C. Look for the /etc/inetd.conf file or /etc/xinetd.d subdirectory, which are signs of inetd or xinetd, respectively.
D. Examine the /etc/inittab file to see which super server is launched by init, which is responsible for this task.
E. Type netstat -a | grep inet and examine the output for signs of inetd or xinetd.
3. How does the lpc utility for CUPS differ from its counterpart in BSD LPD and LPRng?
A. The lpc utility is unique to CUPS; it doesn’t ship with BSD LPD or LPRng.
B. CUPS doesn’t ship with an lpc command, but BSD LPD and LPRng do.
C. CUPS’s lpc is much more complex than its counterpart in BSD LPD and LPRng.
D. CUPS’s lpc is much simpler than its counterpart in BSD LPD and LPRng.
E. The lpc utility is identical in all three of these printing systems.
4. What file would you edit to restrict the number of simultaneous logins a user can employ?
A. /etc/pam.d/login-limits
B. /etc/bashrc
C. /etc/security/limits.conf
D. /etc/inittab
E. /etc/passwd
5. Which of the following are required when configuring a computer to use a static IP address? (Select two.)
A. The IP address of the DHCP server
B. The hostname of the NBNS server
C. The computer’s IP address
D. The network mask
E. The IP address of the NTP server
6. What does the following command accomplish?
$ wc report.txt | tee wc
A. It launches the wc editor on both the report.txt and wc.txt files; each file opens in its own window.
B.report.txtwc