LINUX - download.e-bookshelf.de › download › 0000 › 5934 › ... · About the Author Roderick...

30

Transcript of LINUX - download.e-bookshelf.de › download › 0000 › 5934 › ... · About the Author Roderick...

Page 1: LINUX - download.e-bookshelf.de › download › 0000 › 5934 › ... · About the Author Roderick W. Smith, LPIC-2, LPIC-1, CompTIA Linux+, is a Linux consul- tant, author, and
Page 2: LINUX - download.e-bookshelf.de › download › 0000 › 5934 › ... · About the Author Roderick W. Smith, LPIC-2, LPIC-1, CompTIA Linux+, is a Linux consul- tant, author, and
Page 3: LINUX - download.e-bookshelf.de › download › 0000 › 5934 › ... · About the Author Roderick W. Smith, LPIC-2, LPIC-1, CompTIA Linux+, is a Linux consul- tant, author, and

LINUX®

ESSENTIALS

Page 4: LINUX - download.e-bookshelf.de › download › 0000 › 5934 › ... · About the Author Roderick W. Smith, LPIC-2, LPIC-1, CompTIA Linux+, is a Linux consul- tant, author, and
Page 5: LINUX - download.e-bookshelf.de › download › 0000 › 5934 › ... · About the Author Roderick W. Smith, LPIC-2, LPIC-1, CompTIA Linux+, is a Linux consul- tant, author, and

LINUX®

ESSENTIALS

Roderick W. Smith

Page 6: LINUX - download.e-bookshelf.de › download › 0000 › 5934 › ... · About the Author Roderick W. Smith, LPIC-2, LPIC-1, CompTIA Linux+, is a Linux consul- tant, author, and

Acquisitions Editor: Agatha KimDevelopment Editor: David ClarkTechnical Editor: Ross BrunsonProduction Editor: Rebecca AndersonCopy Editor: Elizabeth WelchEditorial Manager: Pete GaughanProduction Manager: Tim TateVice President and Executive Group Publisher: Richard SwadleyVice President and Publisher: Neil EddeBook Designer: Happenstance Type-O-RamaCompositor: James D. Kramer, Happenstance Type-O-RamaProofreader: Scott Klemp, Word One New YorkIndexer: Ted LauxProject Coordinator, Cover: Katherine CrockerCover Designer: Ryan Sneed

Copyright © 2012 by John Wiley & Sons, Inc., Indianapolis, Indiana Published simultaneously in Canada ISBN: 978-1-118-10679-2 ISBN: 978-1-18-19741-7 (ebk.) ISBN: 978-1-118-19739-4 (ebk.) ISBN: 978-1-118-19740-0 (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 autho-rization 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 recommenda-tions 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: 2011939652

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. Linux is a registered trademark of Linus Torvalds. 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.

10 9 8 7 6 5 4 3 2 1

Page 7: LINUX - download.e-bookshelf.de › download › 0000 › 5934 › ... · About the Author Roderick W. Smith, LPIC-2, LPIC-1, CompTIA Linux+, is a Linux consul- tant, author, and

Dear Reader,

Thank you for choosing Linux Essentials. 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 [email protected]. 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

Page 8: LINUX - download.e-bookshelf.de › download › 0000 › 5934 › ... · About the Author Roderick W. Smith, LPIC-2, LPIC-1, CompTIA Linux+, is a Linux consul- tant, author, and

Ack nowl edgments

Although this book bears my name as its author, many other people contrib-uted to its creation. Without their help, this book wouldn’t exist, or at best would exist in a lesser form. Agatha Kim was the acquisitions editor, and so helped get the book started. Denise Lincoln and David J. Clark, the development editors, and Rebecca Anderson, the production editor, oversaw the book as it progressed through all its stages. Ross Brunson was the technical editor, who checked the text for technical errors and omissions—but any mistakes that remain are my own. Liz Welch, the copy editor, helped keep the text grammatical and under-standable. The proofreader, Scott Klemp, 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.

Page 9: LINUX - download.e-bookshelf.de › download › 0000 › 5934 › ... · About the Author Roderick W. Smith, LPIC-2, LPIC-1, CompTIA Linux+, is a Linux consul- tant, author, and

About the Author

Roderick W. Smith, LPIC-2, LPIC-1, CompTIA Linux+, is a Linux consul-tant, author, and open source programmer. He is the author of over 20 books on Linux and other open source technologies, including Linux+ Complete Study Guide; LPIC-1 Study Guide, 2nd Edition; LPIC-2 Study Guide, and Linux Administrator Street Smarts, all from Sybex.

Page 10: LINUX - download.e-bookshelf.de › download › 0000 › 5934 › ... · About the Author Roderick W. Smith, LPIC-2, LPIC-1, CompTIA Linux+, is a Linux consul- tant, author, and

contents At A gl Ance

Introduction xvii

CHAP TER 1 Selecting an Operating System 1

CHAP TER 2 Investigating Linux’s Principles and Philosophy 21

CHAP TER 3 Understanding Software Licensing 33

CHAP TER 4 Using Common Linux Programs 49

CHAP TER 5 Managing Hardware 75

CHAP TER 6 Getting to Know the Command Line 99

CHAP TER 7 Managing Files 117

CHAP TER 8 Getting Help 131

CHAP TER 9 Using Programs and Processes 149

CHAP TER 10 Searching, Extracting, and Archiving Data 165

CHAP TER 11 Editing Files 185

CHAP TER 12 Creating Scripts 203

CHAP TER 13 Understanding Users and Groups 217

CHAP TER 14 Creating Users and Groups 235

CHAP TER 15 Setting Ownership and Permissions 257

CHAP TER 16 Navigating the Linux Filesystem 271

CHAP TER 17 Managing Network Connections 285

APPENDIX A Answers to Review Questions 307

APPENDIX B LPI’s Certification Program 325

Index 329

Page 11: LINUX - download.e-bookshelf.de › download › 0000 › 5934 › ... · About the Author Roderick W. Smith, LPIC-2, LPIC-1, CompTIA Linux+, is a Linux consul- tant, author, and

contents

Introduction xvii

chApter 1 Select ing an Operating System 1

What Is an OS? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1What Is a Kernel? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1What Else Identifies an OS?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

Investigating User Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4Using a Text-Mode User Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4Using a Graphical User Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

Where Does Linux Fit in the OS World? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8Comparing Linux to Unix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8Comparing Linux to Mac OS X . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10Comparing Linux to Windows. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

What Is a Distribution?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13Creating a Complete Linux-Based OS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13A Summary of Common Linux Distributions . . . . . . . . . . . . . . . . . . . . . . . . . . . 14Understanding Release Cycles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

The Essentials and Beyond. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

chApter 2 Invest igat ing Linux’s Princ iples and Philosophy 21

Linux through the Ages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21Understanding Linux’s Origins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22Seeing Today’s Linux World. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

Using Open Source Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24Understanding Basic Open Source Principles . . . . . . . . . . . . . . . . . . . . . . . . . . . 24Linux as a Software Integrator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

Understanding OS Roles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27Understanding Embedded Computers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27Understanding Desktop and Laptop Computers. . . . . . . . . . . . . . . . . . . . . . . . . . 28Understanding Server Computers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29

The Essentials and Beyond. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30

Page 12: LINUX - download.e-bookshelf.de › download › 0000 › 5934 › ... · About the Author Roderick W. Smith, LPIC-2, LPIC-1, CompTIA Linux+, is a Linux consul- tant, author, and

x C o n t e n t s

chApter 3 Understanding Sof tware Licensing 33

Investigating Software Licenses. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33Copyright and Software. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34Using Licenses to Modify Copyright Terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36

The Free Software Foundation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36Understanding the FSF Philosophy. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37Free Software and the GPL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38

The Open Source Initiative. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39Understanding the Open Source Philosophy . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39Defining Open Source Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40

The Creative Commons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41Using Open Source Licenses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42

Understanding Open Source Licenses. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42Understanding Open Source Business Models . . . . . . . . . . . . . . . . . . . . . . . . . . . 44

The Essentials and Beyond. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45

chApter 4 Using Common Linux Programs 49

Using a Linux Desktop Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49Choosing a Desktop Environment. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50Launching Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52Using a File Manager . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54

Working with Productivity Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56Finding the Right Tool for the Job . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57Using a Web Browser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58Using Email Clients . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59Using Office Tools. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60Using Multimedia Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61Using Linux for Cloud Computing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62Using Mobile Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62

Using Server Programs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63Identifying Common Server Protocols and Programs . . . . . . . . . . . . . . . . . . . . . 63Installing and Launching Servers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67Securing Servers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68

Managing Programming Languages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69Choosing a Compiled vs. an Interpreted Language . . . . . . . . . . . . . . . . . . . . . . . 69Identifying Common Programming Languages . . . . . . . . . . . . . . . . . . . . . . . . . 70

The Essentials and Beyond. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72

Page 13: LINUX - download.e-bookshelf.de › download › 0000 › 5934 › ... · About the Author Roderick W. Smith, LPIC-2, LPIC-1, CompTIA Linux+, is a Linux consul- tant, author, and

C o n t e n t s x i

chApter 5 Managing Hardware 75

Learning About Your CPU . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75Understanding CPU Families. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76Identifying Your CPU . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78

Identifying Motherboard Capabilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78Sizing Your Power Supply. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80Understanding Disk Issues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81

Disk Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81Partitioning a Disk . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81Understanding Filesystem Issues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85Using Removable and Optical Disks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88

Managing Displays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89Understanding the Role of X . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89Using Common Display Hardware. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90

Handling USB Devices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92Managing Drivers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93

Understanding Types of Drivers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93Locating and Installing Drivers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94

The Essentials and Beyond. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95

chApter 6 Get t ing to Know the Command Line 99

Starting a Command Line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99Launching a Terminal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100Logging Into a Text-Mode Console . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102Logging In Remotely . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103

Running Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103Running Text-Mode Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104Running GUI Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105Running Programs in the Background. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105

Manipulating Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106Obtaining File Listings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106Changing Directories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108Using Absolute and Relative File References. . . . . . . . . . . . . . . . . . . . . . . . . . . . 108Using Common File Manipulation Commands . . . . . . . . . . . . . . . . . . . . . . . . . 110

Using Shell Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111Using Command Completion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111Using Command History . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112

The Essentials and Beyond. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114

Page 14: LINUX - download.e-bookshelf.de › download › 0000 › 5934 › ... · About the Author Roderick W. Smith, LPIC-2, LPIC-1, CompTIA Linux+, is a Linux consul- tant, author, and

x i i C o n t e n t s

chApter 7 Managing Fi les 117

Manipulating Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .117Creating Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118Copying Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118Moving and Renaming Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120Using Links. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121Deleting Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122Using Wildcards . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123Understanding Case Sensitivity. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123

Manipulating Directories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124Creating Directories. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125Deleting Directories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125Managing Directories. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127

The Essentials and Beyond. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127

chApter 8 Get t ing Help 131

Using man Pages. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131Understanding the Purpose of man Pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131Locating man Pages by Section Number . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132Searching for a man Page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133Reading man Pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134Using less . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135

Using info Pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138Understanding the Purpose of info Pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138Reading info Pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139

Finding Additional Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140Locating Program Documentation on Your Computer . . . . . . . . . . . . . . . . . . . 141Locating Program Documentation Online. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144Consulting Experts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145

The Essentials and Beyond. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146

chApter 9 Using Programs and Processes 149

Understanding Package Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149Linux Package Management Principles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149Understanding Package Systems. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150Managing RPM Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152Managing Debian Systems. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153

Page 15: LINUX - download.e-bookshelf.de › download › 0000 › 5934 › ... · About the Author Roderick W. Smith, LPIC-2, LPIC-1, CompTIA Linux+, is a Linux consul- tant, author, and

C o n t e n t s x i i i

Understanding the Process Hierarchy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154Identifying Running Processes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155

Using ps to Identify Processes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155Using top to Identify Processes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157Measuring Memory Use . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159

Using Log Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160Locating Log Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160Producing More Verbose Log File Entries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162Examining the Kernel Ring Buffer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162

The Essentials and Beyond. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163

chApter 10 Searching, Extract ing, and Archiving Data 165

Using Regular Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165Searching for and Extracting Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167

Using grep. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168Using find . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170Using wc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171

Redirecting Input and Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172Using Basic Redirection Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173Using Pipes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175Generating Command Lines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175

Archiving Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .176Using tar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .176Using Compression. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179Using zip . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180

The Essentials and Beyond. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183

chApter 11 Edit ing Fi les 185

Understanding the Role of Text Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185Choosing an Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187Launching an Editor. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189Editing Files with pico or nano . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189

Using Text Editor Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190Exploring Basic nano Text-Editing Procedures . . . . . . . . . . . . . . . . . . . . . . . . . 190Saving Your Changes from nano. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193

Editing Files with Vi . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193Understanding Vi Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193Exploring Basic Vi Text-Editing Procedures. . . . . . . . . . . . . . . . . . . . . . . . . . . . 194Saving Your Changes from Vi . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197

Page 16: LINUX - download.e-bookshelf.de › download › 0000 › 5934 › ... · About the Author Roderick W. Smith, LPIC-2, LPIC-1, CompTIA Linux+, is a Linux consul- tant, author, and

x i v C o n t e n t s

Using Configuration File Conventions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197Editing Formatted Text Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199The Essentials and Beyond. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200

chApter 12 Creating Scripts 203

Beginning a Shell Script. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204Using Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204Using Arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207Using Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208Using Conditional Expressions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210Using Loops. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212Using Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213Setting the Script’s Exit Value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214The Essentials and Beyond. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215

chApter 13 Understanding Users and Groups 217

Understanding Accounts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .217Understanding Account Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218Identifying Accounts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220Understanding Groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222

Using Account Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223Discovering Your Own Identity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224Learning Who’s Online . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225

Working as root. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226Why Work as root? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227Acquiring root Privileges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227Using root Privileges Safely . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230

The Essentials and Beyond. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232

chApter 14 Creating Users and Groups 235

Creating New Accounts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235Deciding on a Group Strategy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235Selecting a Good Password . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236Creating Accounts Using GUI Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239Creating Accounts from the Shell . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241

Modifying Accounts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244Deciding When to Modify Accounts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244Checking for Logged-in Users . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245

Page 17: LINUX - download.e-bookshelf.de › download › 0000 › 5934 › ... · About the Author Roderick W. Smith, LPIC-2, LPIC-1, CompTIA Linux+, is a Linux consul- tant, author, and

C o n t e n t s x v

Modifying Accounts Using GUI Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245Modifying Accounts from the Shell. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247

Deleting Accounts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250Avoiding Account-Deletion Pitfalls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250Deleting Accounts Using GUI Tools. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251Deleting Accounts from the Shell . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251

Managing Groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252Managing Groups Using GUI Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252Managing Groups from the Shell . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253

The Essentials and Beyond. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255

chApter 15 Set t ing Ownership and Permissions 257

Setting Ownership . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257Understanding Ownership . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258Setting Ownership in a File Manager . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259Setting Ownership in a Shell. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260

Setting Permissions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261Understanding Permissions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261Setting Permissions in a File Manager . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266Setting Permissions in a Shell. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266Setting the umask . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267

The Essentials and Beyond. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268

chApter 16 Navigating the Linux Fi lesystem 271

Understanding Where Things Go. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271User Files vs. System Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271The Filesystem Hierarchy Standard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273Important Directories and Their Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274

Using Special Permission Bits and File Features. . . . . . . . . . . . . . . . . . . . . . . . . . . 277Using Sticky Bits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 277Using Special Execute Permissions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279Hiding Files from View . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280Viewing Directories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281

The Essentials and Beyond. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 282

chApter 17 Managing Network Connections 285

Understanding Network Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285

Page 18: LINUX - download.e-bookshelf.de › download › 0000 › 5934 › ... · About the Author Roderick W. Smith, LPIC-2, LPIC-1, CompTIA Linux+, is a Linux consul- tant, author, and

x v i C o n t e n t s

Configuring a Network Connection. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287Deciding Whether to Use DHCP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288Creating a Wi-Fi Connection. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289Using a Network Configuration GUI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293Using Text-Based Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295

Testing Your Network Connection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299Checking Your Routing Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299Testing Basic Connectivity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299Finding Breaks in Connectivity. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 300Testing DNS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 302Checking Your Network Status . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 302

Protecting Your System from the Bad Guys . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303The Essentials and Beyond. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 304

Appendix A Answers to Review Questions 307

Chapter 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 307Chapter 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 308Chapter 3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309Chapter 4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 310Chapter 5 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 311Chapter 6 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 312Chapter 7 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 313Chapter 8 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314Chapter 9 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315Chapter 10 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 316Chapter 11 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .317Chapter 12 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 318Chapter 13 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 319Chapter 14 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 320Chapter 15 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 321Chapter 16 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322Chapter 17 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 323

Appendix b LPI’s Cer t i f icat ion Program 325

The Linux Essentials Certification. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325Certification Objectives Map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 326

Index 329

Page 19: LINUX - download.e-bookshelf.de › download › 0000 › 5934 › ... · About the Author Roderick W. Smith, LPIC-2, LPIC-1, CompTIA Linux+, is a Linux consul- tant, author, and

introduc t ionThe book you hold in your hands is an introductory textbook on the Linux operating system. As the title suggests, it provides you with the essential knowl-edge to begin using and managing this powerful operating system (OS), which is an important one in today’s computing world. The following pages describe why you should care about Linux, describe the purpose of the Linux Professional Institute’s Linux Essentials certification, offer advice on who should buy this book, describe how the book is organized, and explain some of the typographi-cal and organizational elements within the book’s chapters.

What Is Linux?Linux is a clone of the Unix OS that has been popular in academic and business environments for years. Linux consists of a kernel, which is the core control soft-ware, 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. Popular Linux distributions include Arch, CentOS, Debian, Fedora, Gentoo, Mandriva, openSUSE, Red Hat, Slackware, SUSE Enterprise, and Ubuntu, but there are hundreds, if not thousands, of other Linux distributions. This book focuses on tools and techniques that are used in most or all distributions, although from time to time it demonstrates more distribution-specific tools.

Linux has several characteristics that make it worth learning and using:

�� Linux is open source software, meaning that the files used to create the working programs that make up Linux are freely available and may be modified and redistributed. Thus, if you dislike something about the way Linux works, you can change it yourself! (You may need modest to considerable programming skill to do so, however.)

�� Linux is available free of charge. Although some distributions require payment, most can be downloaded from the Internet and used with-out paying a cent. This is a great boon for students, businesses on a shoestring budget, or anybody wanting to save money. Those who want to pay for greater support can do so by hiring consultants or purchasing service contracts.

Page 20: LINUX - download.e-bookshelf.de › download › 0000 › 5934 › ... · About the Author Roderick W. Smith, LPIC-2, LPIC-1, CompTIA Linux+, is a Linux consul- tant, author, and

x v i i i I n t r o d u c t i o n

�� As a clone of the older Unix OS, Linux has inherited a great deal of Unix software, including many very important Internet server pro-grams, databases, programming languages, and more.

�� Linux is highly scalable—it runs on everything from cell phones to supercomputers. The Linux versions described in most detail in this book run on a more limited range of hardware, but they can run on PCs that are several years old or on the very latest hardware. Linux can make good use of PCs that are too old for the latest version of Windows.

�� Many businesses and non-profit organizations rely on Linux. Although desktop systems still usually run Windows, Linux is often used to run the organizations’ Web sites, route their Internet traffic, and do other critical behind-the-scenes tasks. In some cases, Linux is used as the desktop OS, too. Thus, learning Linux will help your employment prospects.

You can install Linux on almost any PC on which you normally run Windows or Mac OS X. You can install Linux by itself or side by side with another OS, so you can learn Linux without losing your ability to get work done in your regular OS.

What Is the Linux Essentials Certification?The Linux Professional Institute (LPI; http://www.lpi.org) offers a series of Linux certifications. These certifications aim to provide proof of skill levels for employ-ers; if you’ve passed a particular certification, you should be competent to perform certain tasks on Linux computers. The LPI exams include Linux Essentials, LPIC-1, LPIC-2, and several LPIC-3 exams. As the name implies, the Linux Essentials exam is the lowest-level of the exams, covering the most basic tasks of using and admin-istering a Linux computer. Its specific objectives can be found at http://wiki.lpi.org/wiki/LinuxEssentials. This book covers all of these topics, although not in the exact order in which they appear on the LPI Web site.

Who Should Read This Book?You may have been assigned this book for a class you’re taking, but if not, it can still have value for self-study or as a supplement to other resources. If you’re new to Linux, this book covers the material you will need to learn the OS from the beginning. You can pick up this book and learn from it even if you’ve never used

Page 21: LINUX - download.e-bookshelf.de › download › 0000 › 5934 › ... · About the Author Roderick W. Smith, LPIC-2, LPIC-1, CompTIA Linux+, is a Linux consul- tant, author, and

I n t r o d u c t i o n x i x

Linux before. If you’re already familiar with Linux, you’ll have a leg up on many of the topics described in these pages.

This book is written with the assumption that you know at least a little about computers generally, 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 X. I do not assume that you have knowledge of Linux system administration.

System RequirementsAs a practical matter, you’ll need a Linux system with which to practice and learn in a hands-on way. You can install Linux in several ways:

�� Alone as the only OS on the computer

�� Side by side with another OS

�� In an emulated computer environment provided by a virtualization program such as VMware (http://www.vmware.com) or VirtualBox (http://www.virtualbox.org)

If you’re taking a course on Linux, you may be able to use Linux in a lab envi-ronment, but if you’re using this book in a self-study manner, you should plan to install Linux yourself. Although you can learn something just by reading this book, no amount of reading can substitute for hands-on experience with Linux!

You can use any popular Linux distribution with this book, although if you’re new to Linux, you’ll probably be happiest with one of the more user-friendly distributions, such as CentOS, Fedora, openSUSE, or Ubuntu. This book does not include instructions for how to install Linux; you should consult distribu-tion-specific documentation to help with this task.

To install Linux and use all its GUI tools, your computer should meet the fol-lowing requirements:

CPU 400 MHz Pentium Pro or better

Minimum RAM 640 MiB

Recommended RAM At least 1,152 MiB

Hard disk space At least 9 GiB in unpartitioned space

Some distributions can work on less powerful computers than this, and oth-ers may require better hardware to take full advantage of all features. Consult your distribution’s documentation to fine-tune these requirements.

Page 22: LINUX - download.e-bookshelf.de › download › 0000 › 5934 › ... · About the Author Roderick W. Smith, LPIC-2, LPIC-1, CompTIA Linux+, is a Linux consul- tant, author, and

x x I n t r o d u c t i o n

How This Book Is OrganizedThis book consists of 17 chapters plus this introduction. The chapters are orga-nized as follows:

Chapter 1, “Selecting an Operating System,” provides a birds-eye view of the world of operating systems. This chapter will help you understand what Linux is and the situations in which you might want to use it.

Chapter 2, “Investigating Linux’s Principles and Philosophy,” covers Linux’s history and the ways in which Linux—and other OSs—are commonly used.

Chapter 3, “Understanding Software Licensing,” describes copyright law and the licenses that both Linux and non-Linux OSs use to expand or restrict users’ right to use and copy software.

Chapter 4, “Using Common Linux Programs,” covers the major categories of Linux software and provides pointers to some of the most popular Linux programs.

Chapter 5, “Managing Hardware,” provides advice on how to select and use hardware in Linux. Specific topics range from the central processing unit (CPU) to device drivers.

Chapter 6, “Getting to Know the Command Line,” tackles using typed com-mands to control Linux. Although many new users find this topic intimidating, command-line control of Linux is very important.

Chapter 7, “Managing Files,” describes how to move, rename, delete, and edit files. Directories are just a special type of file and so are covered as well.

Chapter 8, “Getting Help,” covers Linux’s help resources. These include the built-in man and info packages and using off-computer resources such as Web sites.

Chapter 9, “Using Programs and Processes,” describes how you can install programs in Linux and how you can adjust the priority of running programs or terminate selected programs.

Chapter 10, “Searching, Extracting, and Archiving Data,” summarizes tools you can use to find data on your computer, as well as how you can manipulate data archive files for data transport and backup purposes.

Chapter 11, “Editing Files,” introduces the topic of editing text files. This includes basic features of the pico, nano, and Vi text-mode text editors as well as some common configuration file and formatted text file conventions.

Page 23: LINUX - download.e-bookshelf.de › download › 0000 › 5934 › ... · About the Author Roderick W. Smith, LPIC-2, LPIC-1, CompTIA Linux+, is a Linux consul- tant, author, and

I n t r o d u c t i o n x x i

Chapter 12, “Creating Scripts,” describes how to create simple scripts, which are programs that can run other programs. You can use scripts to help automate otherwise tedious manual tasks, thus improving your productivity.

Chapter 13, “Understanding Users and Groups,” introduces the concepts that are critical to understanding Linux’s multi-user nature. It also covers the root account, which Linux uses for most administrative tasks.

Chapter 14, “Creating Users and Groups,” covers the software and proce-dures you use to create, modify, and delete accounts and groups, which define who may use the computer.

Chapter 15, “Setting Ownership and Permissions,” describes how to control which users may access files and in what ways they may do so. In conjunction with users and groups, ownership and permissions control your computer’s security.

Chapter 16, “Navigating the Linux Filesystem,” describes where files go in Linux—where you can look for program files, configuration files, user files, and so on.

Chapter 17, “Managing Network Connections,” covers the critical topic of telling Linux how to use a network, including testing the connection and some basic network security measures.

Broadly speaking, the chapters are arranged in order of increasing complexity of the tasks and systems described. The book begins with background infor-mation on Linux and the philosophies that drive its development. Subsequent chapters describe basic user tasks, such as moving files around. The book concludes with tasks that are of most interest to system administrators, such as account management and network configuration.

Each chapter begins with a list of the topics that are covered in that chapter. At the end of each chapter, you’ll find a few elements that summarize the mate-rial and encourage you to go further:

The Essentials and Beyond This is a one-paragraph summary of the material covered in the chapter. If when you read it something sounds unfamiliar, go back and review the relevant section of the chapter!

Suggested exercises Each chapter includes two to four exercises you should perform to give yourself more hands-on experience with Linux. These exercises do not necessarily have “correct” answers; instead, they’re intended to promote exploration and discovery of your own computer and of Linux.

Review questions Each chapter concludes with a series of nine review ques-tions, in multiple-choice, true/false, or fill-in-the-blank format. (Answers to

Page 24: LINUX - download.e-bookshelf.de › download › 0000 › 5934 › ... · About the Author Roderick W. Smith, LPIC-2, LPIC-1, CompTIA Linux+, is a Linux consul- tant, author, and

x x i i I n t r o d u c t i o n

review questions appear in Appendix A.) These questions can help you test your knowledge and prepare for the Linux Essentials exam. Note, however, that these questions are not taken from LPI’s exam. You should not memorize the answers to these questions and assume that doing so will enable you to pass the exam. Instead, study the text of the book and use Linux.

To get the most out of this book, you should read each chapter from start to finish, perform the suggested exercises, and answer the review questions. Even if you’re already familiar with a topic, you should skim the chapter; Linux is com-plex 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.

Conventions Used in This BookThis 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 onscreen prompts. In particular, look for the following styles:

�� Italicized text indicates key terms that are described or defined for the first time in a chapter. (Italics are also used for emphasis.)

�� Amonospacedfont indicates the contents of configuration files, messages displayed at a text-mode Linux shell prompt, filenames, text-mode command names, and Internet URLs.

�� Italicized monospaced text indicates a variable—information that differs from one system or command run to another, such as the name of a client computer or the name of a user’s data file.

�� Bold monospaced text is information that you’re to type into the computer, usually at a Linux shell prompt. This text can also be itali-cized to indicate that you should substitute an appropriate value for your system. When isolated on their own lines, commands are pre-ceded by non-bold monospaced $ or # command prompts, denoting regular user or system administrator use, respectively.

In addition to these text conventions, which can apply to individual words or entire paragraphs, a few conventions highlight segments of text.

A margin note identifies additional information that may be relevant to the principal point of the accompanying paragraph but that isn’t critical to its basic understanding. This could be a cross-reference to information in another chap-ter, an interesting but non-critical minor fact, or a warning about a rare pitfall of a procedure.

As a general rule, margin notes are best read after the paragraphs to which they refer.

Page 25: LINUX - download.e-bookshelf.de › download › 0000 › 5934 › ... · About the Author Roderick W. Smith, LPIC-2, LPIC-1, CompTIA Linux+, is a Linux consul- tant, author, and

I n t r o d u c t i o n x x i i i

SidebarS

A sidebar is an extended description of a topic that’s related to the main text but that doesn’t fit neatly into the flow of the surrounding paragraphs. It may expand on a point to provide added context or suggest an alternative way of doing things from the method emphasized in the main text.

Many chapters of this book describe both GUI and text-mode methods of accom-plishing the tasks they describe. Because you’re likely to be more familiar with GUI tools, most chapters begin with them; however, in most cases Linux’s text-mode tools are more powerful. Furthermore, the Linux Essentials certification covers mainly text-mode tools. Therefore, you should be sure to learn the text-mode tools. As you gain proficiency with Linux, you’re likely to find yourself using the text-mode tools more than the GUI tools because of the added flexibility the text-mode tools provide. Furthermore, the GUI tools tend to vary a lot between distributions, whereas the text-mode tools vary much less.

Page 26: LINUX - download.e-bookshelf.de › download › 0000 › 5934 › ... · About the Author Roderick W. Smith, LPIC-2, LPIC-1, CompTIA Linux+, is a Linux consul- tant, author, and
Page 27: LINUX - download.e-bookshelf.de › download › 0000 › 5934 › ... · About the Author Roderick W. Smith, LPIC-2, LPIC-1, CompTIA Linux+, is a Linux consul- tant, author, and

CHAPTER 1

Selecting an Operating SystemThe fact that you’re reading this book means you want to learn about the Linux operating system (OS). To begin this journey, you must first under-stand what Linux is and what an OS is. This chapter is therefore devoted to these basic issues. I describe what an OS is, how users interact with an OS, how Linux compares to other OSs with which you may be familiar, and how specific Linux implementations vary. Understanding these issues will help you make your way as you learn about Linux and switch between Linux-based systems and other computers.

II What is an OS?

II Investigating user interfaces

II Where does Linux fit in the OS world?

II What is a distribution?

What Is an OS?An OS provides all the most fundamental features of a computer, at least from a software point of view. An OS enables you to use the computer’s hardware devices, it defines the user interface standards, and it provides basic tools that begin to make the computer useful. Ultimately, many of these features trace their way back to the OS’s kernel, which is described in more detail next. Other OS features are owed to additional programs that run atop the kernel, as described later in this chapter.

What Is a Kernel?An OS kernel is a software component that’s responsible for managing various low-level features of the computer, including:

II Interfacing with hardware devices (network adapters, hard disks, and so on)

Page 28: LINUX - download.e-bookshelf.de › download › 0000 › 5934 › ... · About the Author Roderick W. Smith, LPIC-2, LPIC-1, CompTIA Linux+, is a Linux consul- tant, author, and

2 C h a p t e r 1 • S e l e c t i n g a n O p e r a t i n g S y s t e m

II Allocating memory to individual programs

II Allocating CPU time to individual programs

II Enabling programs to interact with each other

When you use a program (say, a Web browser), it relies on the kernel for many of its basic functions. The Web browser can only communicate with the outside world by using network functions provided by the kernel. The kernel allocates memory and CPU time to the Web browser, without which it couldn’t run. The Web browser may rely on plug-ins to display multimedia content; such programs are launched and interact with the Web browser through kernel services. Similar comments apply to any program you run on a computer, although the details vary from one OS to another and from one program to another.

In sum, the kernel is the software “glue” that holds the computer together. Without a kernel, a modern computer can do very little.

Kernels are not interchangeable; the Linux kernel is different from the Mac OS X kernel or the Windows kernel. Each of these kernels uses a different inter-nal design and provides different software interfaces for programs to use. Thus, each OS is built from the kernel up and uses its own set of programs that fur-ther define each OS’s features.

Linux uses a kernel called Linux—in fact, technically speaking, the word Linux refers only to the kernel. Other features that you might associate with Linux are provided by non-kernel programs, most of which are available on other platforms, as described shortly, in “What Else Identifies an OS.”

A student named Linus Torvalds created the Linux kernel in 1991. Linux has evolved considerably since that time. Today, it runs on a wide variety of CPUs and other hardware. The easiest way to learn about Linux is to use it on a desk-top or laptop PC, so that’s the type of configuration that’s emphasized in this book. The Linux kernel, however, runs on everything from tiny cell phones to powerful supercomputers.

What Else Identifies an OS?The kernel is at the core of any OS, but it’s a component that most users don’t directly manipulate. Instead, most users interact with a number of other soft-ware components, many of which are closely associated with particular OSs. Such programs include the following:

Command-line shells Years ago, users interacted with computers exclu-sively by typing commands in a program (known as a shell) that accepted such

I

Many programs run on multiple kernels, but most need OS-specific tweaks. Programmers create binaries—the pro-gram files for a par-ticular processor and kernel—for each OS.

CertificationObjective

Page 29: LINUX - download.e-bookshelf.de › download › 0000 › 5934 › ... · About the Author Roderick W. Smith, LPIC-2, LPIC-1, CompTIA Linux+, is a Linux consul- tant, author, and

W h a t I s a n O S ? 3

commands. The commands would rename files, launch programs, and so on. Although many computer users today don’t use text-mode shells, they’re still important for intermediate and advanced Linux users, so I describe them in more detail in Chapter 6, “Getting to Know the Command Line,” and subse-quent chapters rely heavily on your ability to use a text-mode shell. Many differ-ent shells are available, and which shells are available and popular differ from one OS to another. In Linux, a shell known as the Bourne Again Shell (bash or Bash) is popular.

Graphical user interfaces A graphical user interface (GUI) is an improvement on a text-mode shell, at least from the perspective of a beginning user. Instead of using typed commands, GUIs rely on icons, menus, and a mouse pointer. Windows and Mac OS both have their own OS-specific GUIs. Linux relies on a GUI known as the X Window System, or X for short. X is a very basic GUI, so Linux also uses desktop environment program suites, such as the GNU Object Model Environment (GNOME) or the K Desktop Environment (KDE), to provide a more complete user experience. It’s the differences between a Linux desktop environment and the GUIs in Windows or OS X that will probably strike you most when you first begin using Linux.

Utility programs Modern OSs invariably ship with a wide variety of simple utility programs—calculators, calendars, text editors, disk maintenance tools, and so on. These programs differ from one OS to another. Indeed, even the names and methods of launching these programs can differ between OSs. Fortunately, you can usually find the programs you want by perusing menus in the main desktop environment.

Libraries Unless you’re a programmer, you’re unlikely to need to work with libraries directly; nonetheless, I include them in this list because they provide critical services to programs. Libraries are collections of programming func-tions that can be used by a variety of programs. For instance, in Linux most programs rely on a library called libc. Other libraries provide features associ-ated with the GUI or that help programs parse options passed to them on the command line. Many libraries exist for Linux, which helps enrich the Linux software landscape.

Productivity programs Major productivity programs—Web browsers, word processors, graphics editors, and so on—are the usual reason for using a com-puter. Although such programs are often technically separate from the OS, they are sometimes associated with certain OSs. Even when a program is available on many OSs, it may have a different “feel” on each OS because of the different GUIs and other OS-specific features.

CertificationObjective

You can search for Linux equivalents to popular Mac OS X or Windows pro-grams on Web sites such as http://www.linuxrsp.ru/win-lin-soft/table-eng or http://www.linuxalt.com.

J

Page 30: LINUX - download.e-bookshelf.de › download › 0000 › 5934 › ... · About the Author Roderick W. Smith, LPIC-2, LPIC-1, CompTIA Linux+, is a Linux consul- tant, author, and

4 C h a p t e r 1 • S e l e c t i n g a n O p e r a t i n g S y s t e m

In addition to software that runs on an OS, several other features can distin-guish between OSs, such as the details of user accounts, rules for naming disk files, and technical details of how the computer starts up. These features are all controlled by software that’s part of the OS, of course—sometimes by the kernel and sometimes by non-kernel software.

Investigating User InterfacesEarlier, I noted the distinction between text-mode and graphical user interfaces. Although most end users favor GUIs because of their ease of use, Linux retains a strong text-mode tradition. Chapter 6 describes Linux’s text-mode tools in more detail, and Chapter 4, “Using Common Linux Programs,” covers basic princi-ples of Linux GUI operations. It’s important that you have some grounding in the basic principles of both text-mode and graphical user interfaces now, since user interface issues crop up from time to time in intervening chapters.

Using a Text-Mode User InterfaceIn the past, and even sometimes today, Linux computers booted in text mode. Once the system had completely booted, the screen would display a simple text-mode login prompt, which might resemble this:

DebianGNU/Linux6.0essentialstty1

essentialslogin:

The details of such a login prompt vary from one system to another. This example includes several pieces of information:

II The OS name and version—Debian GNU/Linux 6.0

II The computer’s name—essentials

II The name of the hardware device being used for the login—tty1

II The login prompt itself—login:

To log in to such a system, you must type your username at the login: prompt. The system then prompts you for a password, which you must also type. If you entered a valid username and password, the computer is likely to display a login message, followed by a shell prompt:

rodsmith@essentials:~$

CertificationObjective

I

To try a text-mode login, you must first install Linux on a computer. Neither the Linux Essentials exam nor this book covers Linux installation; consult your distribu-tion’s documentation to learn more.

I

If you see a GUI login prompt, you can obtain a text-mode prompt by pressing Ctrl+Alt+F1 or Ctrl+Alt+F2. To return to the GUI login prompt, press Alt+F1 or Alt+F7.