image

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

It Pays to Get Certified

image

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.

image

Certification Helps Your Career

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.

image 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 Career Pathway

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.

image

Steps to Certification

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.

Join the Professional Community

The free IT Pro online community (http://itpro.comptia.org) provides valuable content to students and professionals.

Content Seal of Quality

image 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.

Why CompTIA?

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.

How to Obtain More Information

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

image

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,

image

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.


image
In 2010, CompTIA announced a partnership with Linux Professional Institute, the organization behind the popular LPI Certification (LPIC) program. With this partnership, CompTIA offers the LPIC Level 1 exams under the Linux+ umbrella. The exams and the exam objectives are identical for the two programs; however, Linux+ candidates have the option of receiving their LPIC-1 as well as the Novell Certified Linux Administrator certification by passing the CompTIA Linux+ exams.

What Is Linux?

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.

Why Become Linux Certified?

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.

How to Become Certified

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).


image
As noted above, if you take and pass the CompTIA Linux+ exams, you do have the option of also obtaining your LPIC-1 certification from LPI, as well as your Novell Certified Linux Administrator (CLA) certification at the same time. All that is required is authorization to submit your information to LPI. You are given this option at the testing site.

Who Should Buy This Book

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.


image
As a practical matter, you’ll need a Linux system with which to practice and learn in a hands-on way. Neither the exams nor this book covers actually installing Linux on a computer from scratch, although some of the prerequisites (such as disk partitioning) are covered. You may need to refer to your distribution’s documentation to learn how to accomplish this task. Alternatively, several vendors sell computers with Linux pre-installed.

How This Book Is Organized

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.


image
The review questions, assessment test, and other testing elements included in this book are not derived from the actual exam questions, so don’t memorize the answers to these questions and assume that doing so will enable you to pass the exam. You should learn the underlying topic, as described in the text of the book. This will let you answer the questions provided with this book and pass the exam. Learning the underlying topic is also the approach that will serve you best in the workplace—the ultimate goal of a certification.

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.

Additional Study Tools

Readers of this book can access a Web site that contains several additional study tools, including the following:


image
Readers can access these tools by visiting http://www.sybex.com/go/linuxplus2e.

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.

Conventions Used in This Book

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:


image
A note indicates information that’s useful or interesting but that’s somewhat peripheral to the main text. A note might be relevant to a small number of networks, for instance, or it may refer to an outdated feature.


image
A tip provides information that can save you time or frustration and that may not be entirely obvious. A tip might describe how to get around a limitation or how to use a feature to perform an unusual task.


image
Warnings describe potential pitfalls or dangers. If you fail to heed a warning, you may end up spending a lot of time recovering from a bug, or you may even end up restoring your entire system from scratch.


Sidebar
A sidebar is like a note but longer. The information in a sidebar is useful, but it doesn’t fit into the main flow of the text.


image
Real World Scenario
A real world scenario is a type of sidebar that describes a task or example that’s particularly grounded in the real world. This may be a situation I or somebody I know has encountered, or it may be advice on how to work around problems that are common in real, working Linux environments.


EXERCISE: EXERCISE
An exercise is a procedure you should try on your own computer to help you learn about the material in the chapter. Don’t limit yourself to the procedures described in the exercises, though! Try other commands and procedures to really learn about Linux.

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.)


image
Exam objectives are subject to change at any time without prior notice and at CompTIA’s sole discretion. Please visit CompTIA’s Web site (http://certification.comptia.org/home.aspx) for the most current listing of exam objectives.

Exam LX0-101 Objectives

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%

101 System Architecture

101.1 Determine and Configure hardware settings (Chapter 3)

101.2 Boot the System (Chapter 5)

101.3 Change runlevels and shutdown or reboot system (Chapter 5)

102 Linux Installation and Package Management

102.1 Design hard disk layout (Chapter 3)

102.2 Install a boot manager (Chapter 5)

102.3 Manage shared libraries (Chapter 2)

102.4 Use Debian package management (Chapter 2)

102.5 Use RPM and YUM package management (Chapter 2)

103 GNU and Unix Commands

103.1 Work on the command line (Chapter 1)

103.2 Process text streams using filters (Chapter 1)

103.3 Perform basic file management (Chapter 4)

103.4 Use streams, pipes and redirects (Chapter 1)

103.5 Create, monitor and kill processes (Chapter 2)

103.6 Modify process execution priorities (Chapter 2)

103.7 Search text files using regular expressions (Chapter 1)

103.8 Perform basic file editing operations using vi (Chapter 5)

104 Devices, Linux Filesystems, Filesystem Hierarchy Standard

104.1 Create partitions and filesystems (Chapter 3)

104.2 Maintain the integrity of filesystems (Chapter 3)

104.3 Control mounting and unmounting of filesystems (Chapter 3)

104.4 Manage disk quotas (Chapter 4)

104.5 Manage file permissions and ownership (Chapter 4)

104.6 Create and change hard and symbolic links (Chapter 4)

104.7 Find system files and place files in the correct location (Chapter 4)

Exam LX0-102 Objectives

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%

105 Shells, Scripting and Data Management

105.1 Customize and use the shell environment (Chapter 9)

105.2 Customize or write simple scripts (Chapter 9)

105.3 SQL data management (Chapter 9)

106 User Interfaces and Desktops

106.1 Install and configure X11 (Chapter 6)

106.2 Setup a display manager (Chapter 6)

106.3 Accessibility (Chapter 6)

107 Administrative Tasks

107.1 Manage user and group accounts and related system files (Chapter 7)

107.2 Automate system administration tasks by scheduling jobs (Chapter 9)

107.3 Localization and internationalization (Chapter 6)

108 Essential System Services

108.1 Maintain system time (Chapter 7)

108.2 System logging (Chapter 7)

108.3 Mail Transfer Agent (MTA) basics (Chapter 9)

108.4 Manage printers and printing (Chapter 6)

109 Networking Fundamentals

109.1 Fundamentals of internet protocols (Chapter 8)

109.2 Basic network configuration (Chapter 8)

109.3 Basic network troubleshooting (Chapter 8)

109.4 Configure client side DNS (Chapter 8)

110 Security

110.1 Perform security administration tasks (Chapter 10)

110.2 Setup host security (Chapter 10)

110.3 Securing data with encryption (Chapter 10)

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