Table Of ContentNETWORKING
Linux+ and LPIC-1
Guide to
Linux Certification
Fifth Edition
Jason W. Eckert
triOS College
Australia • Brazil • Mexico • Singapore • United Kingdom • United States
Linux+ and LPIC-1 Guide to Linux © 2020, 2016 Cengage Learning, Inc.
Certification, 5th edition Unless otherwise noted, all content is © Cengage.
Jason Eckert and triOS College
Unless otherwise noted, all screenshots are from Red Hat, Inc./Fedora
SVP, Higher Education & Skills Product: Erin
ALL RIGHTS RESERVED. No part of this work covered by the copyright
Joyner
herein may be reproduced or distributed in any form or by any means,
VP, Product Management: Mike Schenk
except as permitted by U.S. copyright law, without the prior written
Product Director: Lauren Murphy
permission of the copyright owner.
Product Team Manager: Kristin McNary
Product Manager: Amy Savino
For product information and technology assistance, contact us at
Product Assistant: Thomas Benedetto
Cengage Customer & Sales Support, 1-800-354-9706 or
Director, Learning Design: Rebecca von
Gillern support.cengage.com.
Senior Manager, Learning Design: Leigh
For permission to use material from this text or product, submit all
Hefferon
requests online at www.cengage.com/permissions.
Learning Designer: Natalie Onderdonk
Vice President, Marketing – Science,
Technology, & Math: Jason Sakos Library of Congress Control Number: 2019935400
Senior Marketing Director: Michele McTighe ISBN: 978-1-337-56979-8
Associate Marketing Manager: Cassie LLF IBSN: 978-1-337-68441-5
Cloutier
Product Specialist: Mackenzie Paine Cengage
Director, Content Creation: Juliet Steiner 20 Channel Center Street
Senior Manager, Content Creation: Patty Boston, MA 02210
Stephan
USA
Senior Content Manager: Brooke
Greenhouse
Cengage is a leading provider of customized learning solutions with
Director, Digital Production Services: Krista
employees residing in nearly 40 different countries and sales in more
Kellman
than 125 countries around the world. Find your local representative at
Digital Delivery Lead: Jim Vaughey
www.cengage.com.
Designer: Erin Griffin
Cover Designer: Joseph Villanova
Cengage products are represented in Canada by Nelson Education, Ltd.
Cover image: iStock.com/kotkoa
Technical Editor: Danielle Shaw To learn more about Cengage platforms and services, register or access
Developmental Editor: Lisa Ruffalo your online learning solution, or purchase materials for your course,
Production Service/Composition: SPi Global visit www.cengage.com.
Notice to the Reader
Publisher does not warrant or guarantee any of the products described herein or perform any independent analysis in
connection with any of the product information contained herein. Publisher does not assume, and expressly disclaims,
any obligation to obtain and include information other than that provided to it by the manufacturer. The reader is
expressly warned to consider and adopt all safety precautions that might be indicated by the activities described herein
and to avoid all potential hazards. By following the instructions contained herein, the reader willingly assumes all risks
in connection with such instructions. The publisher makes no representations or warranties of any kind, including but
not limited to, the warranties of fitness for particular purpose or merchantability, nor are any such representations
implied with respect to the material set forth herein, and the publisher takes no responsibility with respect to such
material. The publisher shall not be liable for any special, consequential, or exemplary damages resulting, in whole or
part, from the readers’ use of, or reliance upon, this material. https://mail.yahoo.com/d/folders/50
Printed in the United States of America
Print Number: 01 Print Year: 2019
Brief Contents
INTRODUCTION ������������������������������������������������������������������������������������������xvii
CHAPTER 1
Introduction to Linux ������������������������������������������������������������������������������������1
CHAPTER 2
Linux Installation and Usage ���������������������������������������������������������������������49
CHAPTER 3
Exploring Linux Filesystems ����������������������������������������������������������������������93
CHAPTER 4
Linux Filesystem Management ���������������������������������������������������������������147
CHAPTER 5
Linux Filesystem Administration ������������������������������������������������������������205
CHAPTER 6
Linux Server Deployment ������������������������������������������������������������������������281
CHAPTER 7
Working with the BASH Shell �������������������������������������������������������������������339
CHAPTER 8
System Initialization, X Windows, and Localization �����������������������������413
CHAPTER 9
Managing Linux Processes�����������������������������������������������������������������������461
CHAPTER 10
Common Administrative Tasks ���������������������������������������������������������������501
CHAPTER 11
Compression, System Backup, and Software Installation �������������������555
CHAPTER 12
Network Configuration ����������������������������������������������������������������������������621
CHAPTER 13
Configuring Network Services and Cloud Technologies ����������������������683
iii
iv Brief Contents
CHAPTER 14
Security, Troubleshooting, and Performance ........................................751
APPENDIX A
Certification ............................................................................................... 821
APPENDIX B
GNU Public License ................................................................................... 827
APPENDIX C
Finding Linux Resources on the Internet ............................................... 841
APPENDIX D
Applying Your Linux Knowledge to macOS ............................................ 847
GLOSSARY ................................................................................................... 859
INDEX .......................................................................................................... 889
Table of Contents
INTRODUCTION ����������������������������������������������������������������������������������������� xvii
CHAPTER 1
Introduction to Linux ...............................................................1
OPERATING SYSTEMS ��������������������������������������������������������������������������������������������1
THE LINUX OPERATING SYSTEM ��������������������������������������������������������������������������4
Versions of the Linux Operating System �����������������������������������������������������������4
Identifying Kernel Versions �������������������������������������������������������������������������������5
Licensing Linux ��������������������������������������������������������������������������������������������������7
Linux Advantages �������������������������������������������������������������������������������������������� 10
THE HISTORY OF LINUX ��������������������������������������������������������������������������������������17
UNIX ������������������������������������������������������������������������������������������������������������������17
The Hacker Culture �������������������������������������������������������������������������������������������18
Linux ����������������������������������������������������������������������������������������������������������������20
LINUX DISTRIBUTIONS ���������������������������������������������������������������������������������������21
COMMON USES OF LINUX ����������������������������������������������������������������������������������26
Internet Servers �����������������������������������������������������������������������������������������������26
File and Print Servers ����������������������������������������������������������������������������������������34
Application Servers �������������������������������������������������������������������������������������������35
Cloud Systems �������������������������������������������������������������������������������������������������36
Supercomputers ������������������������������������������������������������������������������������������������38
Scientific/Engineering Workstations ���������������������������������������������������������������39
Office/Personal Workstations ��������������������������������������������������������������������������40
Cybersecurity Workstations������������������������������������������������������������������������������41
Mobile Devices ��������������������������������������������������������������������������������������������������41
CHAPTER SUMMARY �������������������������������������������������������������������������������������������42
KEY TERMS �����������������������������������������������������������������������������������������������������������43
REvIEW QUESTIONS ��������������������������������������������������������������������������������������������44
DISCOvERY EXERCISES ����������������������������������������������������������������������������������������46
CHAPTER 2
Linux Installation and Usage .................................................49
INSTALLING LINUX ����������������������������������������������������������������������������������������������49
Preparing for Installation ��������������������������������������������������������������������������������50
Understanding Installation Media ������������������������������������������������������������������50
Performing the Installation ������������������������������������������������������������������������������55
v
vi Table of Contents
BASIC LINUX USAGE ��������������������������������������������������������������������������������������������67
Shells, Terminals, and the Kernel ���������������������������������������������������������������������67
Basic Shell Commands �������������������������������������������������������������������������������������71
Shell Metacharacters ����������������������������������������������������������������������������������������74
Getting Command Help ������������������������������������������������������������������������������������75
Shutting Down the Linux System ��������������������������������������������������������������������81
CHAPTER SUMMARY �������������������������������������������������������������������������������������������82
KEY TERMS �����������������������������������������������������������������������������������������������������������83
REvIEW QUESTIONS ��������������������������������������������������������������������������������������������83
HANDS-ON PROjECTS �����������������������������������������������������������������������������������������85
Project 2-1 ����������������������������������������������������������������������������������������������������������85
Project 2-2 ��������������������������������������������������������������������������������������������������������86
Project 2-3 ���������������������������������������������������������������������������������������������������������87
Project 2-4 ��������������������������������������������������������������������������������������������������������88
Project 2-5 ��������������������������������������������������������������������������������������������������������89
Project 2-6 ��������������������������������������������������������������������������������������������������������90
Project 2-7 ���������������������������������������������������������������������������������������������������������91
DISCOvERY EXERCISES ����������������������������������������������������������������������������������������91
CHAPTER 3
Exploring Linux Filesystems ..................................................93
THE LINUX DIRECTORY STRUCTURE ������������������������������������������������������������������93
Changing Directories ���������������������������������������������������������������������������������������95
vIEWING FILES AND DIRECTORIES���������������������������������������������������������������������98
File Types ���������������������������������������������������������������������������������������������������������98
Filenames ���������������������������������������������������������������������������������������������������������99
Listing Files ����������������������������������������������������������������������������������������������������100
Wildcard Metacharacters ��������������������������������������������������������������������������������106
DISPLAYING THE CONTENTS OF TEXT FILES ���������������������������������������������������107
DISPLAYING THE CONTENTS OF BINARY FILES ����������������������������������������������114
SEARCHING FOR TEXT WITHIN FILES ��������������������������������������������������������������116
Regular Expressions ����������������������������������������������������������������������������������������117
The grep Command ����������������������������������������������������������������������������������������118
EDITING TEXT FILES �������������������������������������������������������������������������������������������120
The vi Editor ����������������������������������������������������������������������������������������������������121
Other Common Text Editors ���������������������������������������������������������������������������129
CHAPTER SUMMARY �����������������������������������������������������������������������������������������132
KEY TERMS ���������������������������������������������������������������������������������������������������������133
REvIEW QUESTIONS ������������������������������������������������������������������������������������������133
Table of Contents vii
HANDS-ON PROjECTS ���������������������������������������������������������������������������������������135
Project 3-1 ��������������������������������������������������������������������������������������������������������135
Project 3-2 �������������������������������������������������������������������������������������������������������137
Project 3-3 �������������������������������������������������������������������������������������������������������137
Project 3-4 �������������������������������������������������������������������������������������������������������139
Project 3-5 �������������������������������������������������������������������������������������������������������139
Project 3-6 �������������������������������������������������������������������������������������������������������143
Project 3-7 �������������������������������������������������������������������������������������������������������143
DISCOvERY EXERCISES ��������������������������������������������������������������������������������������144
CHAPTER 4
Linux Filesystem Management ...........................................147
THE FILESYSTEM HIERARCHY STANDARD �������������������������������������������������������148
MANAGING FILES AND DIRECTORIES ��������������������������������������������������������������149
FINDING FILES ���������������������������������������������������������������������������������������������������155
LINKING FILES ����������������������������������������������������������������������������������������������������160
FILE AND DIRECTORY PERMISSIONS ���������������������������������������������������������������164
File and Directory Ownership ������������������������������������������������������������������������165
Managing File and Directory Permissions �����������������������������������������������������169
Default Permissions ����������������������������������������������������������������������������������������177
Special Permissions ����������������������������������������������������������������������������������������179
Setting Custom Permissions in the Access Control List (ACL) �����������������������184
Managing Filesystem Attributes ��������������������������������������������������������������������185
CHAPTER SUMMARY �����������������������������������������������������������������������������������������186
KEY TERMS ���������������������������������������������������������������������������������������������������������187
REvIEW QUESTIONS ������������������������������������������������������������������������������������������187
HANDS-ON PROjECTS ���������������������������������������������������������������������������������������190
Project 4-1 ��������������������������������������������������������������������������������������������������������190
Project 4-2 ��������������������������������������������������������������������������������������������������������191
Project 4-3 �������������������������������������������������������������������������������������������������������192
Project 4-4 �������������������������������������������������������������������������������������������������������193
Project 4-5 �������������������������������������������������������������������������������������������������������194
Project 4-6 �������������������������������������������������������������������������������������������������������195
Project 4-7 �������������������������������������������������������������������������������������������������������195
Project 4-8 �������������������������������������������������������������������������������������������������������197
Project 4-9 �������������������������������������������������������������������������������������������������������198
Project 4-10 �����������������������������������������������������������������������������������������������������199
Project 4-11 �����������������������������������������������������������������������������������������������������200
DISCOvERY EXERCISES ��������������������������������������������������������������������������������������201
viii Table of Contents
CHAPTER 5
Linux Filesystem Administration ����������������������������������������205
THE /dEv diRECToRy ����������������������������������������������������������������������������������������206
FilEsysTEms ������������������������������������������������������������������������������������������������������210
Filesystem Types ���������������������������������������������������������������������������������������������211
Mounting ��������������������������������������������������������������������������������������������������������213
WoRking WiTH UsB FlAsH mEmoRy dRivEs ����������������������������������������������215
WoRking WiTH Cds, dvds, And iso imAgEs �����������������������������������������������225
WoRking WiTH REmovABlE mEdiA WiTHin A gUi EnviRonmEnT ���������228
WoRking WiTH HARd disks And ssds ��������������������������������������������������������230
Standard Hard Disk Partitioning ��������������������������������������������������������������������231
Working with Standard Hard Disk Partitions �������������������������������������������������235
Working with the LVM ������������������������������������������������������������������������������������247
moniToRing FilEsysTEms �����������������������������������������������������������������������������255
Disk Usage �������������������������������������������������������������������������������������������������������255
Checking Filesystems for Errors ���������������������������������������������������������������������259
disk QUoTAs �����������������������������������������������������������������������������������������������������262
CHAPTER sUmmARy �����������������������������������������������������������������������������������������266
kEy TERms ���������������������������������������������������������������������������������������������������������267
REviEW QUEsTions ������������������������������������������������������������������������������������������268
HAnds-on PRojECTs ���������������������������������������������������������������������������������������270
Project 5-1 ��������������������������������������������������������������������������������������������������������270
Project 5-2 �������������������������������������������������������������������������������������������������������271
Project 5-3 �������������������������������������������������������������������������������������������������������272
Project 5-4 �������������������������������������������������������������������������������������������������������274
Project 5-5 �������������������������������������������������������������������������������������������������������276
Project 5-6 �������������������������������������������������������������������������������������������������������276
Project 5-7 �������������������������������������������������������������������������������������������������������278
disCovERy ExERCisEs ��������������������������������������������������������������������������������������279
CHAPTER 6
Linux Server Deployment ����������������������������������������������������281
UndERsTAnding sERvER HARdWARE �����������������������������������������������������������281
UndERsTAnding sERvER viRTUAlizATion ��������������������������������������������������283
ConFigURing sERvER sToRAgE ��������������������������������������������������������������������287
SCSI Configuration ������������������������������������������������������������������������������������������288
RAID Configuration �����������������������������������������������������������������������������������������289
SAN Storage Configuration �����������������������������������������������������������������������������294
ZFS Configuration �������������������������������������������������������������������������������������������299
Table of Contents ix
BTRFS Configuration ���������������������������������������������������������������������������������������305
Server Storage Configuration Scenarios ��������������������������������������������������������309
INSTALLING A LINUX SERvER DISTRIBUTION�������������������������������������������������309
Dealing with Problems during Installation �����������������������������������������������������311
Dealing with Problems after Installation �������������������������������������������������������312
SYSTEM RESCUE �������������������������������������������������������������������������������������������������320
CHAPTER SUMMARY �����������������������������������������������������������������������������������������321
KEY TERMS ���������������������������������������������������������������������������������������������������������322
REvIEW QUESTIONS ������������������������������������������������������������������������������������������323
HANDS-ON PROjECTS ���������������������������������������������������������������������������������������325
Project 6-1 �������������������������������������������������������������������������������������������������������325
Project 6-2 �������������������������������������������������������������������������������������������������������327
Project 6-3 �������������������������������������������������������������������������������������������������������328
Project 6-4 �������������������������������������������������������������������������������������������������������331
Project 6-5 �������������������������������������������������������������������������������������������������������332
Project 6-6 �������������������������������������������������������������������������������������������������������334
Project 6-7 �������������������������������������������������������������������������������������������������������335
DISCOvERY EXERCISES ��������������������������������������������������������������������������������������337
CHAPTER 7
Working with the BASH Shell ...............................................339
COMMAND INPUT AND OUTPUT ��������������������������������������������������������������������339
Redirection ������������������������������������������������������������������������������������������������������341
Pipes ����������������������������������������������������������������������������������������������������������������345
SHELL vARIABLES ����������������������������������������������������������������������������������������������358
Environment Variables �����������������������������������������������������������������������������������358
User-Defined Variables �����������������������������������������������������������������������������������363
Other Variables �����������������������������������������������������������������������������������������������365
Environment Files ������������������������������������������������������������������������������������������366
SHELL SCRIPTS ���������������������������������������������������������������������������������������������������367
Escape Sequences �������������������������������������������������������������������������������������������370
Reading Standard Input ����������������������������������������������������������������������������������371
Decision Constructs ����������������������������������������������������������������������������������������372
Loop Constructs ���������������������������������������������������������������������������������������������380
Special Variables ���������������������������������������������������������������������������������������������385
Functions ��������������������������������������������������������������������������������������������������������389
vERSION CONTROL USING GIT ������������������������������������������������������������������������391
CHAPTER SUMMARY �����������������������������������������������������������������������������������������397
KEY TERMS ���������������������������������������������������������������������������������������������������������398