Table Of ContentThis is an electronic version of the print textbook. Due to electronic rights restrictions, some third party content may be suppressed. Editorial
review has deemed that any suppressed content does not materially affect the overall learning experience. The publisher reserves the right to
remove content from this title at any time if subsequent rights restrictions require it. For valuable information on pricing, previous
editions, changes to current editions, and alternate formats, please visit www.cengage.com/highered to search by
ISBN#, author, title, or keyword for materials in your areas of interest.
Linux Operations and Administration
Alfred Basta
Dustin A. Finamore
Nadine Basta
Serge Palladino
LinuxOperationsandAdministration ©2013CourseTechnology,CengageLearning
AlfredBasta,DustinA.Finamore, ALLRIGHTSRESERVED.Nopartofthisworkcoveredbythe
NadineBasta,SergePalladino copyrighthereinmaybereproduced,transmitted,storedorused
inanyformorbyanymeansgraphic,electronic,ormechanical,
VicePresident,Careers&Computing:
includingbutnotlimitedtophotocopying,recording,scanning,
DaveGarza
digitizing,taping,Webdistribution,informationnetworks,or
DirectorofLearningSolutions: informationstorageandretrievalsystems,exceptaspermitted
MatthewKane underSection107or108ofthe1976UnitedStatesCopyrightAct,
withoutthepriorwrittenpermissionofthepublisher.
ExecutiveEditor:SteveHelba
AcquisitionsEditor:NickLombardi Forproductinformationandtechnologyassistance,contactusat
ManagingEditor:MarahBellegarde CengageLearningCustomer&SalesSupport,1-800-354-9706
ProductManager:NataliePashoukos Forpermissiontousematerialfromthistextorproduct,
submitallrequestsonlineatcengage.com/permissions
DevelopmentEditor:LisaM.Lord
Furtherpermissionsquestionscanbeemailedto
EditorialAssistant:SarahPickering permissionrequest@cengage.com
VicePresident,Marketing:
JenniferAnnBaker LibraryofCongressControlNumber:2012938293
MarketingDirector:DeborahYarnell ISBN-13:978-1-1110-3530-3
AssociateMarketingManager: ISBN-10:1-1110-3530-X
EricaGlisson
CourseTechnology
ProductionDirector:WendyA.Troeger
20ChannelCenterStreet
ProductionManager:AndrewCrouth Boston,MA02210
USA
SeniorContentProjectManager:
CengageLearningisaleadingproviderofcustomizedlearning
AndreaMajot
solutionswithofficelocationsaroundtheglobe,including
SeniorArtDirector:JackPendleton Singapore,theUnitedKingdom,Australia,Mexico,Brazil,and
TechnologyProjectManager:JoePliss Japan.Locateyourlocalofficeat:international.cengage.com/region
CengageLearningproductsarerepresentedinCanadabyNelson
MediaEditor:WilliamOverocker
Education,Ltd.
Foryourlifelonglearningsolutions,visit
www.cengage.com/coursetechnology
Purchaseanyofourproductsatyourlocalcollegestoreoratour
preferredonlinestorewww.cengagebrain.com
Visitourcorporatewebsiteatcengage.com.
Someoftheproductnamesandcompanynamesusedinthisbookhavebeenusedforidentificationpurposesonlyandmaybetrademarksor
registeredtrademarksoftheirrespectivemanufacturersandsellers.
MicrosoftandtheOfficelogoareeitherregisteredtrademarksortrademarksofMicrosoftCorporationintheUnitedStatesand/orother
countries.CourseTechnology,apartofCengageLearning,isanindependententityfromtheMicrosoftCorporationandnotaffiliatedwith
Microsoftinanymanner.
AnyfictionaldatarelatedtopersonsorcompaniesorURLsusedthroughoutthisbookisintendedforinstructionalpurposesonly.Atthetime
thisbookwasprinted,anysuchdatawasfictionalandnotbelongingtoanyrealpersonsorcompanies.
CourseTechnologyandtheCourseTechnologylogoareregisteredtrademarksusedunderlicense.
CourseTechnology,apartofCengageLearning,reservestherighttorevisethispublicationandmakechangesfromtimetotimeinits
contentwithoutnotice.
Theprogramsinthisbookareforinstructionalpurposesonly.Theyhavebeentestedwithcare,butarenotguaranteedforanyparticularintent
beyondeducationalpurposes.Theauthorandthepublisherdonotofferanywarrantiesorrepresentations,nordotheyacceptanyliabilitieswith
respecttotheprograms.
Screenshotsofsoftwareprogramsandoperatingsystemsincludedinthistextarecourtesyofthefollowingcompanies:openSUSE,VMware
Player,DomainNameSystem,andMicrosoft.
Printed in the United States of America
1 2 3 4 5 6 7 16 15 14 13 12
Brief Contents
INTRODUCTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xv
CHAPTER 1
Introductionto theLinuxOperatingSystem .. ... ... .. ... .. ... ... .. ... ... .. ... ... .. ... .. 1
CHAPTER 2
InstallingOpenSUSE... ... .. ... .. ... ... .. ... ... .. ... .. ... ... .. ... ... .. ... ... .. ... . 15
CHAPTER 3
ManagingFilesandDirectories .. .. ... ... .. ... ... .. ... .. ... ... .. ... ... .. ... ... .. ... . 41
CHAPTER 4
CreatingandEditingFileswithTextEditors .. ... ... .. ... .. ... ... .. ... ... .. ... ... .. ... . 71
CHAPTER 5
CreatingShell ScriptsandDisplaying FileContents ... .. ... .. ... ... .. ... ... .. ... ... .. ... . 89
CHAPTER 6
ManagingData:BackupandRecovery Processes.. ... .. ... .. ... ... .. ... ... .. ... ... .. ... 121
CHAPTER 7
ManagingUsersandGroups . ... .. ... ... .. ... ... .. ... .. ... ... .. ... ... .. ... ... .. ... 143
CHAPTER 8
NetworkCommunications . .. ... .. ... ... .. ... ... .. ... .. ... ... .. ... ... .. ... ... .. ... 167
CHAPTER 9
InstallingSoftwarePackages . ... .. ... ... .. ... ... .. ... .. ... ... .. ... ... .. ... ... .. ... 187
CHAPTER 10
ApacheWebServer ... ... .. ... .. ... ... .. ... ... .. ... .. ... ... .. ... ... .. ... ... .. ... 207
CHAPTER 11
DomainNameSystem . ... .. ... .. ... ... .. ... ... .. ... .. ... ... .. ... ... .. ... ... .. ... 229
CHAPTER 12
ConfiguringaMailServer . .. ... .. ... ... .. ... ... .. ... .. ... ... .. ... ... .. ... ... .. ... 249
CHAPTER 13
WorkingwiththeNetwork FileSystem. ... .. ... ... .. ... .. ... ... .. ... ... .. ... ... .. ... 267
CHAPTER 14
Planningfora LinuxInstallation . .. ... ... .. ... ... .. ... .. ... ... .. ... ... .. ... ... .. ... 287
CHAPTER 15
LinuxFileSystem ManagementandAdministration .. .. ... .. ... ... .. ... ... .. ... ... .. ... 307
CHAPTER 16
ManagingResourcesinLinux. ... .. ... ... .. ... ... .. ... .. ... ... .. ... ... .. ... ... .. ... 325
CHAPTER 17
NetworkinginaLinuxEnvironment ... ... .. ... ... .. ... .. ... ... .. ... ... .. ... ... .. ... 351
CHAPTER 18
UsingSambaforInteroperatingLinux andWindows.. .. ... .. ... ... .. ... ... .. ... ... .. ... 371
CHAPTER 19
SecuringLinux .. .. ... ... .. ... .. ... ... .. ... ... .. ... .. ... ... .. ... ... .. ... ... .. ... 389
iii
iv BriefContents
CHAPTER 20
AdvancedLinux Administration. ... .. ... .. ... ... .. ... ... .. ... ... .. ... .. ... ... .. ... . 415
GLOSSARY. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 451
INDEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 459
Table of Contents
INTRODUCTION . .. ... ... .. ... .. ... ... .. ... ... .. ... .. ... ... .. ... ... .. ... ... .. ... . xv
CHAPTER 1
Introductionto theLinuxOperatingSystem .. ... ... .. ... .. ... ... .. ... ... .. ... ... .. ... .. 1
OverviewofOperatingSystemFunctions.................................................... 2
SoftwareLicensingAgreements........................................................ 2
Activity1-1:ReviewingLicensingAgreements ............................................. 3
FunctionsofanOperatingSystem...................................................... 3
HistoryofLinux ..................................................................... 4
OverviewofSUSE ................................................................. 6
LinuxArchitecture.................................................................... 6
Kernel.......................................................................... 7
LinuxDesktopEnvironments ......................................................... 8
LinuxFileStructure ................................................................ 8
FeaturesofLinux.................................................................. 9
CommandShellsAvailableinLinux ................................................... 10
ChapterSummary ................................................................... 11
KeyTerms......................................................................... 11
ReviewQuestions.................................................................... 12
CaseProjects....................................................................... 14
CHAPTER 2
InstallingOpenSUSE... ... .. ... .. ... ... .. ... ... .. ... .. ... ... .. ... ... .. ... ... .. ... . 15
CheckingYourSystemConfiguration ..................................................... 16
RequirementsforInstallingLinux ..................................................... 17
TheUnifiedInstallationMethodwithVirtualMachines ........................................ 17
OverviewofVMwarePlayer......................................................... 18
Activity2-1:DownloadingVMwarePlayer .............................................. 19
InstallingVMwarePlayeronaWindowsHost............................................ 20
Activity2-2:InstallingVMwarePlayer3.1.5onaWindowsHost .............................. 20
InstallingOpenSUSE ................................................................. 20
Activity2-3:CreatingaVirtualMachine ................................................ 21
OpenSUSEBootOptions ........................................................... 21
ThePreparationPhase ............................................................. 24
TheInstallationPhase.............................................................. 27
TheConfigurationPhase............................................................ 28
Activity2-4:InstallingOpenSUSEasaGuestOS .......................................... 30
TheGNOMEDesktopEnvironment ...................................................... 31
FeaturesofGNOME .............................................................. 31
Activity2-5:WorkingwiththeGNOMEDesktopEnvironment................................ 34
TheKDEDesktopEnvironment ......................................................... 34
FeaturesofKDE.................................................................. 35
Activity2-6:WorkingwithKDE...................................................... 36
ChapterSummary ................................................................... 36
KeyTerms......................................................................... 37
ReviewQuestions.................................................................... 38
CaseProjects....................................................................... 39
v
vi TableofContents
CHAPTER 3
ManagingFilesandDirectories . ... .. ... .. ... ... .. ... ... .. ... ... .. ... .. ... ... .. ... .. 41
AnOverviewoftheLinuxDirectoryStructure............................................... 42
NavigatingtheLinuxDirectoryStructure................................................... 44
ChangingDirectories .............................................................. 45
Activity3-1:UsingthepwdandcdCommands ........................................... 47
ViewingFilesandDirectories ........................................................ 47
Activity3-2:UsingthelsCommand................................................... 50
GettingHelp .................................................................... 51
Activity3-3:WorkingwithManPages ................................................. 53
UsingWildcards.................................................................. 53
Activity3-4:UsingWildcards ........................................................ 55
ManagingFilesandDirectories.......................................................... 55
CreatingandDeletingDirectoriesandFiles .............................................. 55
Activity3-5:CreatingandDeletingDirectoriesandFiles..................................... 58
Moving,Renaming,andCopyingFiles.................................................. 59
Activity3-6:Renaming,Moving,andCopyingFiles........................................ 59
CreatingLinks................................................................... 60
Activity3-7:WorkingwithLinks ..................................................... 62
SwitchingUsersandBecomingRoot ................................................... 63
Activity3-8:SwitchingUsers......................................................... 64
ChapterSummary ................................................................... 65
KeyTerms......................................................................... 65
ReviewQuestions.................................................................... 66
CaseProjects....................................................................... 69
CHAPTER 4
Creating andEditingFileswithText Editors . ... ... .. ... ... .. ... ... .. ... .. ... ... .. ... .. 71
TextEditorsinLinux................................................................. 72
GUITextEditorsinLinux .......................................................... 72
Activity4-1:ExploringtheKWriteTextEditor............................................ 73
Activity4-2:ExploringtheGeditTextEditor............................................. 75
GettingStartedwiththeVimEditor....................................................... 76
StartingVim .................................................................... 76
CommandMode ................................................................. 77
Activity4-3:UsingViminCommandMode.............................................. 78
InsertMode..................................................................... 79
Activity4-4:UsingViminInsertMode ................................................. 80
DeletingText.................................................................... 81
Activity4-5:ModifyingTextinVim ................................................... 82
ExtendedMode.................................................................. 83
Activity4-6:UsingViminExtendedMode .............................................. 85
ChapterSummary ................................................................... 86
KeyTerms......................................................................... 86
ReviewQuestions.................................................................... 86
CaseProjects....................................................................... 88
CHAPTER 5
Creating ShellScriptsandDisplaying File Contents .. .. ... ... .. ... ... .. ... .. ... ... .. ... .. 89
AnOverviewofLinuxFilePermissions .................................................... 90
PermissionCommands............................................................. 91
TableofContents vii
CreatingShellScripts ................................................................. 93
Activity5-1:CreatingaShellScript.................................................... 94
Variables....................................................................... 95
Activity5-2:UsingtheDirectAssignmentMethod ......................................... 96
Activity5-3:UsingthePromptMethod ................................................. 98
Activity5-4:UsingPositionalParameters............................................... 100
ExitStatusCodes................................................................ 101
Conditions..................................................................... 101
Activity5-5:UsingConditionStatements............................................... 102
Activity5-6:CreatingaMenuScript.................................................. 104
Activity5-7:UsingcaseStatementsinaMenuScript...................................... 106
Looping....................................................................... 107
Activity5-8:CreatingawhileLoop.................................................. 108
Activity5-9:CreatinganuntilLoopinaMenuScript.................................... 110
Activity5-10:CreatingaforLoop................................................... 112
DisplayingtheContentsofaTextFile.................................................... 112
ThecatandtacCommands....................................................... 112
TheheadandtailCommands..................................................... 113
ThemoreandlessCommands..................................................... 113
ChapterSummary .................................................................. 115
KeyTerms........................................................................ 116
ReviewQuestions................................................................... 116
CaseProjects...................................................................... 118
CHAPTER 6
ManagingData:BackupandRecovery Processes.. ... .. ... .. ... ... .. ... ... .. ... ... .. ... 121
SystemBackups.................................................................... 122
TheTarUtility.................................................................. 123
Activity6-1:UsingtheTarUtility.................................................... 124
Activity6-2:UsingtheAdvancedTarOptions ........................................... 126
Activity6-3:UsingTarOptionstoModifyArchiveMembers’FileInformation.................... 127
Activity6-4:PerformingFullandIncrementalBackupswiththeTarUtility ...................... 129
TheCpioUtility................................................................. 130
Activity6-5:UsingtheCpioUtility ................................................... 132
Compression ...................................................................... 133
TheGzipUtility................................................................. 133
Activity6-6:UsingtheGzipUtility ................................................... 134
TheBzip2Utility ................................................................ 135
Activity6-7:UsingtheBzip2Utility................................................... 135
SchedulingBackups ................................................................. 136
UserCronTables................................................................ 137
Activity6-8:EditingaUserCronTable................................................ 138
SystemCronTable............................................................... 138
ChapterSummary .................................................................. 139
KeyTerms........................................................................ 140
ReviewQuestions................................................................... 140
CaseProjects...................................................................... 142
viii TableofContents
CHAPTER 7
ManagingUsersandGroups ... ... .. ... .. ... ... .. ... ... .. ... ... .. ... .. ... ... .. ... . 143
ManagingUsers.................................................................... 144
The/etc/passwdFile ........................................................... 144
The/etc/shadowFile ........................................................... 145
UserAccountInformation.......................................................... 145
CreatingUserAccounts ........................................................... 147
Activity7-1:CreatingUsers ........................................................ 148
ModifyingUserAccounts.......................................................... 149
Activity7-2:ModifyingUserAccounts................................................. 151
DeletingUserAccounts............................................................ 152
ManagingGroups .................................................................. 153
The/etc/groupFile ............................................................ 153
CreatingGroups ................................................................ 153
ModifyingGroups............................................................... 154
Activity7-3:WorkingwithGroups................................................... 154
ManagingUserandGroupAccountswithYaST ............................................ 155
AddingorEditingUserAccounts..................................................... 156
DefaultsforNewUsers............................................................ 160
AuthenticationSettings............................................................ 161
Activity7-4:UsingtheYaSTUserandGroupManagementUtility............................. 162
ChapterSummary .................................................................. 163
KeyTerms........................................................................ 164
ReviewQuestions................................................................... 164
CaseProjects...................................................................... 166
CHAPTER 8
NetworkCommunications .. ... ... .. ... .. ... ... .. ... ... .. ... ... .. ... .. ... ... .. ... . 167
IntroductiontoTCP/IP............................................................... 168
Activity8-1:ResearchingtheTCP/IPProtocolSuite ....................................... 168
WorkingwithTCP/IP............................................................. 169
WorkingwithIPAddresses............................................................ 172
BinaryandDecimalNumberingSystems ............................................... 172
Activity8-2:ConvertingfromDecimaltoBinary ......................................... 174
NetworkandHostIdentifiers ....................................................... 175
SubnetMasks .................................................................. 175
IPAddressClasses ............................................................... 176
ConfiguringNetworkInterfaceCards .................................................... 177
UsingtheifconfigCommand ..................................................... 177
Activity8-3:UsingtheifconfigCommand............................................ 178
ThepingCommand ............................................................. 179
Activity8-4:UsingthepingCommand................................................ 180
ChapterSummary .................................................................. 181
KeyTerms........................................................................ 182
ReviewQuestions................................................................... 182
CaseProjects...................................................................... 185