100% found this document useful (3 votes)
24 views

Using and Administering Linux: Volume 3, Zero to SysAdmin: Network Services, 2nd Edition David Both - Download the ebook in PDF with all chapters to read anytime

The document provides information about various eBooks available for download at ebookmeta.com, including titles focused on Linux administration and other subjects. It highlights the second edition of 'Using and Administering Linux: Volume 3, Zero to SysAdmin: Network Services' by David Both, along with links to additional related eBooks. The document also includes details about the book's copyright, publication, and technical review information.

Uploaded by

umbojairva
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (3 votes)
24 views

Using and Administering Linux: Volume 3, Zero to SysAdmin: Network Services, 2nd Edition David Both - Download the ebook in PDF with all chapters to read anytime

The document provides information about various eBooks available for download at ebookmeta.com, including titles focused on Linux administration and other subjects. It highlights the second edition of 'Using and Administering Linux: Volume 3, Zero to SysAdmin: Network Services' by David Both, along with links to additional related eBooks. The document also includes details about the book's copyright, publication, and technical review information.

Uploaded by

umbojairva
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 70

Read Anytime Anywhere Easy Ebook Downloads at ebookmeta.

com

Using and Administering Linux: Volume 3, Zero to


SysAdmin: Network Services, 2nd Edition David Both

https://ebookmeta.com/product/using-and-administering-linux-
volume-3-zero-to-sysadmin-network-services-2nd-edition-
david-both/

OR CLICK HERE

DOWLOAD EBOOK

Visit and Get More Ebook Downloads Instantly at https://ebookmeta.com


Recommended digital products (PDF, EPUB, MOBI) that
you can download immediately if you are interested.

Using And Administering Linux: Volume 1 Zero To SysAdmin:


Getting Started 2nd Edition David Both

https://ebookmeta.com/product/using-and-administering-linux-
volume-1-zero-to-sysadmin-getting-started-2nd-edition-david-both/

ebookmeta.com

Using and Administering Linux: Volume 1: Zero to SysAdmin:


Getting Started, 2nd Edition David Both

https://ebookmeta.com/product/using-and-administering-linux-
volume-1-zero-to-sysadmin-getting-started-2nd-edition-david-both-2/

ebookmeta.com

Using And Administering Linux: Volume 2 Zero To SysAdmin:


Advanced Topics (2nd ed.) 2nd Edition David Both

https://ebookmeta.com/product/using-and-administering-linux-
volume-2-zero-to-sysadmin-advanced-topics-2nd-ed-2nd-edition-david-
both/
ebookmeta.com

Racism in Psychology Challenging Theory Practice and


Institutions 1st Edition Craig Newnes (Editor)

https://ebookmeta.com/product/racism-in-psychology-challenging-theory-
practice-and-institutions-1st-edition-craig-newnes-editor/

ebookmeta.com
The Heiress of All Things Beautiful 1st Edition Anita
Stansfield

https://ebookmeta.com/product/the-heiress-of-all-things-beautiful-1st-
edition-anita-stansfield/

ebookmeta.com

A Background to the Study of English Literature 2nd


Edition B. Prasad (Brijadish Prasad)

https://ebookmeta.com/product/a-background-to-the-study-of-english-
literature-2nd-edition-b-prasad-brijadish-prasad/

ebookmeta.com

Mesozoic Stratigraphy of India A Multi Proxy Approach 1st


Edition Santanu Banerjee

https://ebookmeta.com/product/mesozoic-stratigraphy-of-india-a-multi-
proxy-approach-1st-edition-santanu-banerjee/

ebookmeta.com

The Best Recipes to Elevate Your Chicken Wing Game 1st


Edition Sophia Freeman

https://ebookmeta.com/product/the-best-recipes-to-elevate-your-
chicken-wing-game-1st-edition-sophia-freeman/

ebookmeta.com

English Swahili Swahili English Immersive Dictionary 1st


Edition Fidèle Mpiranya

https://ebookmeta.com/product/english-swahili-swahili-english-
immersive-dictionary-1st-edition-fidele-mpiranya/

ebookmeta.com
Psycho Oncology 2021 William Breitbart Editor Phyllis
Butow Editor Paul Jacobsen Editor Wendy Lam Editor Mark
Lazenby Editor Matthew Loscalzo Editor
https://ebookmeta.com/product/psycho-oncology-2021-william-breitbart-
editor-phyllis-butow-editor-paul-jacobsen-editor-wendy-lam-editor-
mark-lazenby-editor-matthew-loscalzo-editor/
ebookmeta.com
Using and Administering
Linux: Volume 3
Zero to SysAdmin: Network Services
Second Edition

David Both
Using and Administering Linux: Volume 3: Zero to SysAdmin: Network Services
David Both
Raleigh, NC, USA

ISBN-13 (pbk): 978-1-4842-9785-8 ISBN-13 (electronic): 978-1-4842-9786-5


https://doi.org/10.1007/978-1-4842-9786-5

Copyright © 2023 by David Both


This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the
material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation,
broadcasting, reproduction on microfilms or in any other physical way, and transmission or information
storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now
known or hereafter developed.
Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with
every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an
editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the
trademark.
The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not
identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to
proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of publication,
neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or
omissions that may be made. The publisher makes no warranty, express or implied, with respect to the
material contained herein.
Managing Director, Apress Media LLC: Welmoed Spahr
Acquisitions Editor: James Robinson-Prior
Development Editor: Jim Markham
Editorial Assistant: Gryffin Winkler
Cover image designed by the author
Distributed to the book trade worldwide by Springer Science+Business Media New York, 1 New York Plaza,
1 FDR Dr, New York, NY 10004. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders-ny@springer-
sbm.com, or visit www.springeronline.com. Apress Media, LLC is a California LLC and the sole member
(owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a
Delaware corporation.
For information on translations, please e-mail booktranslations@springernature.com; for reprint,
paperback, or audio rights, please e-mail bookpermissions@springernature.com.
Apress titles may be purchased in bulk for academic, corporate, or promotional use. eBook versions and
licenses are also available for most titles. For more information, reference our Print and eBook Bulk Sales
web page at http://www.apress.com/bulk-sales.
Any source code or other supplementary material referenced by the author in this book is available to
readers on GitHub (https://github.com/Apress). For more detailed information, please visit https://www.
apress.com/gp/services/source-code.
Paper in this product is recyclable
This book is dedicated to all
Linux and open source developers, system administrators,
course developers, and trainers.
:(){ :|:& };:
Table of Contents
About the Author���������������������������������������������������������������������������������������������������xvii

About the Technical Reviewers������������������������������������������������������������������������������xix


Acknowledgments��������������������������������������������������������������������������������������������������xxi

Introduction����������������������������������������������������������������������������������������������������������xxiii

Chapter 42: Server Preparation�������������������������������������������������������������������������������� 1


Objectives������������������������������������������������������������������������������������������������������������������������������������� 1
Overview��������������������������������������������������������������������������������������������������������������������������������������� 2
Creating the VM����������������������������������������������������������������������������������������������������������������������������� 2
Installing Linux������������������������������������������������������������������������������������������������������������������������������ 4
Personalization and Updates��������������������������������������������������������������������������������������������������� 6
Virtual Network Configuration������������������������������������������������������������������������������������������������������� 7
Adjusting the Firewall����������������������������������������������������������������������������������������������������������������� 20
Overview of DHCP����������������������������������������������������������������������������������������������������������������������� 22
Installing the DHCP Server���������������������������������������������������������������������������������������������������� 23
Configuring the DHCP Server������������������������������������������������������������������������������������������������� 24
Configuring the Client Host���������������������������������������������������������������������������������������������������� 29
Configuring Guest Hosts�������������������������������������������������������������������������������������������������������� 31
The Final dhcpd.conf File������������������������������������������������������������������������������������������������������ 34
Configuring NTP with Chrony������������������������������������������������������������������������������������������������������ 35
Configuring the NTP Server��������������������������������������������������������������������������������������������������� 35
Configure and Test the NTP Client����������������������������������������������������������������������������������������� 37
Chapter Summary����������������������������������������������������������������������������������������������������������������������� 40
Exercises������������������������������������������������������������������������������������������������������������������������������������� 40

v
Table of Contents

Chapter 43: Name Services������������������������������������������������������������������������������������ 43


Objectives����������������������������������������������������������������������������������������������������������������������������������� 43
Introducing Domain Name Services�������������������������������������������������������������������������������������������� 43
How a Name Search Works��������������������������������������������������������������������������������������������������������� 44
Top-Level Configuration�������������������������������������������������������������������������������������������������������������� 46
NSS and NSSwitch���������������������������������������������������������������������������������������������������������������� 46
resolv.conf����������������������������������������������������������������������������������������������������������������������������� 50
systemd-resolved.service����������������������������������������������������������������������������������������������������� 53
Name Service Strategies������������������������������������������������������������������������������������������������������������ 54
The /etc/hosts File����������������������������������������������������������������������������������������������������������������� 54
mDNS������������������������������������������������������������������������������������������������������������������������������������ 58
nss-DNS��������������������������������������������������������������������������������������������������������������������������������� 60
Using BIND���������������������������������������������������������������������������������������������������������������������������������� 70
Preparation���������������������������������������������������������������������������������������������������������������������������� 71
Setting Up the Caching Name Server������������������������������������������������������������������������������������ 74
Configuring the Firewall for DNS������������������������������������������������������������������������������������������� 77
Start the Name Service��������������������������������������������������������������������������������������������������������� 78
Reconfiguring DHCP�������������������������������������������������������������������������������������������������������������� 80
Using the Top-Level DNS Servers������������������������������������������������������������������������������������������ 81
Creating a Primary Name Server������������������������������������������������������������������������������������������������ 82
Creating the Forward Zone File��������������������������������������������������������������������������������������������� 82
Adding the Forward Zone File to named.conf������������������������������������������������������������������������ 84
Adding CNAME Records��������������������������������������������������������������������������������������������������������� 85
Creating the Reverse Zone File���������������������������������������������������������������������������������������������� 87
Adding the Reverse Zone to named.conf������������������������������������������������������������������������������� 88
Automating BIND Administration������������������������������������������������������������������������������������������������� 91
Chapter Summary����������������������������������������������������������������������������������������������������������������������� 91
Exercises������������������������������������������������������������������������������������������������������������������������������������� 92

vi
Table of Contents

Chapter 44: Routing������������������������������������������������������������������������������������������������ 93


Objectives����������������������������������������������������������������������������������������������������������������������������������� 93
Introduction��������������������������������������������������������������������������������������������������������������������������������� 93
Routing on a Workstation������������������������������������������������������������������������������������������������������������ 94
Creating a Router������������������������������������������������������������������������������������������������������������������������ 96
Setting Up the Router������������������������������������������������������������������������������������������������������������������ 97
Kernel Configuration�������������������������������������������������������������������������������������������������������������� 97
Firewall State������������������������������������������������������������������������������������������������������������������������ 99
Firewall Requirements�������������������������������������������������������������������������������������������������������� 100
Zones����������������������������������������������������������������������������������������������������������������������������������� 100
Adapting the Firewall���������������������������������������������������������������������������������������������������������� 105
Network Routing����������������������������������������������������������������������������������������������������������������������� 107
Complex Routing����������������������������������������������������������������������������������������������������������������������� 109
Fail2Ban������������������������������������������������������������������������������������������������������������������������������������ 110
Cleanup������������������������������������������������������������������������������������������������������������������������������������� 113
Chapter Summary��������������������������������������������������������������������������������������������������������������������� 114
Exercises����������������������������������������������������������������������������������������������������������������������������������� 114

Chapter 45: Remote Access with SSH������������������������������������������������������������������ 115


Objectives��������������������������������������������������������������������������������������������������������������������������������� 115
Introduction������������������������������������������������������������������������������������������������������������������������������� 115
Starting the SSH Server������������������������������������������������������������������������������������������������������������ 117
How SSH Works – Briefly���������������������������������������������������������������������������������������������������������� 119
Public/Private Key Pairs������������������������������������������������������������������������������������������������������������ 120
How PPKPs Work����������������������������������������������������������������������������������������������������������������� 120
X-Forwarding���������������������������������������������������������������������������������������������������������������������������� 126
The X Window System�������������������������������������������������������������������������������������������������������������� 129
Remote Commands������������������������������������������������������������������������������������������������������������������� 130
Remote Backups����������������������������������������������������������������������������������������������������������������� 131
Chapter Summary��������������������������������������������������������������������������������������������������������������������� 133
Exercises����������������������������������������������������������������������������������������������������������������������������������� 133

vii
Table of Contents

Chapter 46: Security��������������������������������������������������������������������������������������������� 135


Objectives��������������������������������������������������������������������������������������������������������������������������������� 135
Introduction������������������������������������������������������������������������������������������������������������������������������� 136
Security by Obscurity���������������������������������������������������������������������������������������������������������� 137
What Is Security?���������������������������������������������������������������������������������������������������������������� 138
Data Protection�������������������������������������������������������������������������������������������������������������������� 138
Security Vectors������������������������������������������������������������������������������������������������������������������������ 139
Self-Inflicted Problems�������������������������������������������������������������������������������������������������������� 139
Environmental Problems����������������������������������������������������������������������������������������������������� 140
Physical Attacks������������������������������������������������������������������������������������������������������������������ 141
Network Attacks������������������������������������������������������������������������������������������������������������������ 141
Software Vulnerabilities������������������������������������������������������������������������������������������������������� 142
Linux and Security�������������������������������������������������������������������������������������������������������������������� 143
Login Security���������������������������������������������������������������������������������������������������������������������� 143
Telnet����������������������������������������������������������������������������������������������������������������������������������� 151
Some Basic Steps��������������������������������������������������������������������������������������������������������������������� 155
PAM������������������������������������������������������������������������������������������������������������������������������������������� 158
Advanced DNS Security������������������������������������������������������������������������������������������������������������ 160
About chroot������������������������������������������������������������������������������������������������������������������������ 160
Enabling bind-chroot����������������������������������������������������������������������������������������������������������� 160
Hardening the Network in the Kernel���������������������������������������������������������������������������������������� 163
Restrict SSH Root Login������������������������������������������������������������������������������������������������������������ 165
More firewalld��������������������������������������������������������������������������������������������������������������������������� 166
Disabling All Traffic in Case of Emergency Using CLI���������������������������������������������������������� 167
Access from Specific IP Addresses or Networks����������������������������������������������������������������� 168
Malware������������������������������������������������������������������������������������������������������������������������������������ 171
Root Kits������������������������������������������������������������������������������������������������������������������������������ 171
ClamAV�������������������������������������������������������������������������������������������������������������������������������� 176
Tripwire�������������������������������������������������������������������������������������������������������������������������������� 179

viii
Table of Contents

SELinux������������������������������������������������������������������������������������������������������������������������������������� 182
Additional SELinux Considerations�������������������������������������������������������������������������������������� 188
Social Engineering�������������������������������������������������������������������������������������������������������������������� 188
Chapter Summary��������������������������������������������������������������������������������������������������������������������� 189
Exercises����������������������������������������������������������������������������������������������������������������������������������� 190

Chapter 47: Back Up Everything – Frequently������������������������������������������������������ 193


Introduction������������������������������������������������������������������������������������������������������������������������������� 193
Backups to the Rescue������������������������������������������������������������������������������������������������������������� 194
The Problem������������������������������������������������������������������������������������������������������������������������ 194
Backup Options������������������������������������������������������������������������������������������������������������������������� 200
tar���������������������������������������������������������������������������������������������������������������������������������������������� 201
Off-Site Backups����������������������������������������������������������������������������������������������������������������������� 205
Disaster Recovery Services������������������������������������������������������������������������������������������������������ 207
Options�������������������������������������������������������������������������������������������������������������������������������������� 207
What About the “Frequently” Part?������������������������������������������������������������������������������������������� 208
How Frequent Is “Frequently?”������������������������������������������������������������������������������������������� 208
What Does “Full” Really Mean?������������������������������������������������������������������������������������������� 209
All vs. Diff���������������������������������������������������������������������������������������������������������������������������� 210
Considerations for Automation of Backups������������������������������������������������������������������������� 210
Dealing with Offline Hosts��������������������������������������������������������������������������������������������������� 210
Advanced Backups�������������������������������������������������������������������������������������������������������������������� 211
rsync������������������������������������������������������������������������������������������������������������������������������������ 211
Performing Backups������������������������������������������������������������������������������������������������������������ 217
Recovery Testing����������������������������������������������������������������������������������������������������������������� 220
Chapter Summary��������������������������������������������������������������������������������������������������������������������� 220
Exercises����������������������������������������������������������������������������������������������������������������������������������� 221

Chapter 48: Introducing Email������������������������������������������������������������������������������ 223


Objectives��������������������������������������������������������������������������������������������������������������������������������� 223
Introduction������������������������������������������������������������������������������������������������������������������������������� 223
Definitions��������������������������������������������������������������������������������������������������������������������������� 224

ix
Table of Contents

Email Data Flow������������������������������������������������������������������������������������������������������������������������ 225


Structure of an Email����������������������������������������������������������������������������������������������������������� 227
Email Headers��������������������������������������������������������������������������������������������������������������������� 227
Sendmail on the Server������������������������������������������������������������������������������������������������������������ 232
Sendmail Installation����������������������������������������������������������������������������������������������������������� 233
Sendmail Configuration������������������������������������������������������������������������������������������������������� 234
DNS Configuration��������������������������������������������������������������������������������������������������������������� 245
Sendmail on the Client�������������������������������������������������������������������������������������������������������������� 246
SMTP: The Protocol������������������������������������������������������������������������������������������������������������������� 250
Email-Only Accounts����������������������������������������������������������������������������������������������������������������� 254
Who Gets Email for Root?��������������������������������������������������������������������������������������������������������� 255
Things to Remember����������������������������������������������������������������������������������������������������������������� 257
It Is Not Instant�������������������������������������������������������������������������������������������������������������������� 257
There Is No Delivery Guarantee������������������������������������������������������������������������������������������� 257
Chapter Summary��������������������������������������������������������������������������������������������������������������������� 258
Exercises����������������������������������������������������������������������������������������������������������������������������������� 258

Chapter 49: Advanced Email Topics��������������������������������������������������������������������� 261


Objectives��������������������������������������������������������������������������������������������������������������������������������� 261
Introduction������������������������������������������������������������������������������������������������������������������������������� 261
The Real Problem with Email���������������������������������������������������������������������������������������������������� 262
Preparation������������������������������������������������������������������������������������������������������������������������������� 263
More mailx�������������������������������������������������������������������������������������������������������������������������������� 263
Setup����������������������������������������������������������������������������������������������������������������������������������������� 269
Installing IMAP on the Server���������������������������������������������������������������������������������������������������� 270
Installing UW IMAP�������������������������������������������������������������������������������������������������������������� 271
Installing Dovecot IMAP������������������������������������������������������������������������������������������������������� 273
Testing IMAP������������������������������������������������������������������������������������������������������������������������ 274
Email Clients����������������������������������������������������������������������������������������������������������������������������� 276
Alpine���������������������������������������������������������������������������������������������������������������������������������� 277
Thunderbird������������������������������������������������������������������������������������������������������������������������� 294

x
Table of Contents

Adding Authentication to the Server����������������������������������������������������������������������������������������� 306


SMTP Authentication����������������������������������������������������������������������������������������������������������� 307
Certificates�������������������������������������������������������������������������������������������������������������������������������� 314
Other Considerations���������������������������������������������������������������������������������������������������������������� 315
Resources��������������������������������������������������������������������������������������������������������������������������������� 315
Chapter Summary��������������������������������������������������������������������������������������������������������������������� 316
Exercises����������������������������������������������������������������������������������������������������������������������������������� 316

Chapter 50: Combating Spam������������������������������������������������������������������������������� 319


Objectives��������������������������������������������������������������������������������������������������������������������������������� 319
Introduction������������������������������������������������������������������������������������������������������������������������������� 319
The Problem������������������������������������������������������������������������������������������������������������������������������ 320
But Why?����������������������������������������������������������������������������������������������������������������������������������� 321
My Email Server������������������������������������������������������������������������������������������������������������������������ 321
Project Requirements��������������������������������������������������������������������������������������������������������������� 322
Procmail������������������������������������������������������������������������������������������������������������������������������������ 323
How It Works����������������������������������������������������������������������������������������������������������������������������� 324
Preparation������������������������������������������������������������������������������������������������������������������������������� 325
Configuration���������������������������������������������������������������������������������������������������������������������������� 326
Configuring Sendmail���������������������������������������������������������������������������������������������������������� 326
Hacking mimedefang-filter�������������������������������������������������������������������������������������������������� 330
Configuring Procmail����������������������������������������������������������������������������������������������������������� 338
SpamAssassin Rules����������������������������������������������������������������������������������������������������������� 342
Additional Resources���������������������������������������������������������������������������������������������������������������� 346
Chapter Summary��������������������������������������������������������������������������������������������������������������������� 347
Exercises����������������������������������������������������������������������������������������������������������������������������������� 348

Chapter 51: Apache Web Server��������������������������������������������������������������������������� 349


Objectives��������������������������������������������������������������������������������������������������������������������������������� 349
Introduction������������������������������������������������������������������������������������������������������������������������������� 349
Installing Apache����������������������������������������������������������������������������������������������������������������������� 350
Testing Apache�������������������������������������������������������������������������������������������������������������������������� 350

xi
Table of Contents

Creating a Simple Index File����������������������������������������������������������������������������������������������������� 353


Adding DNS������������������������������������������������������������������������������������������������������������������������������� 356
Good Practice Configuration����������������������������������������������������������������������������������������������������� 357
Virtual Hosts������������������������������������������������������������������������������������������������������������������������������ 358
Configuring the Primary Virtual Host����������������������������������������������������������������������������������� 358
Configuring the Second Virtual Host������������������������������������������������������������������������������������ 360
Using Telnet to Test the Website����������������������������������������������������������������������������������������������� 361
Using CGI Scripts���������������������������������������������������������������������������������������������������������������������� 364
Using Perl���������������������������������������������������������������������������������������������������������������������������� 364
Using Bash��������������������������������������������������������������������������������������������������������������������������� 366
Redirecting the Web Page to CGI����������������������������������������������������������������������������������������� 367
Refreshing the Page Automatically�������������������������������������������������������������������������������������� 369
Chapter Summary��������������������������������������������������������������������������������������������������������������������� 369
Exercises����������������������������������������������������������������������������������������������������������������������������������� 370

Chapter 52: WordPress����������������������������������������������������������������������������������������� 371


Objectives��������������������������������������������������������������������������������������������������������������������������������� 371
Introduction������������������������������������������������������������������������������������������������������������������������������� 371
Install PHP and MariaDB����������������������������������������������������������������������������������������������������������� 372
Install WordPress���������������������������������������������������������������������������������������������������������������������� 373
HTTPD Configuration����������������������������������������������������������������������������������������������������������������� 375
Creating the WordPress Database��������������������������������������������������������������������������������������������� 375
Configuring WordPress�������������������������������������������������������������������������������������������������������������� 377
Administering WordPress���������������������������������������������������������������������������������������������������������� 380
Updating WordPress������������������������������������������������������������������������������������������������������������������ 382
Exploring MariaDB�������������������������������������������������������������������������������������������������������������������� 383
Chapter Summary��������������������������������������������������������������������������������������������������������������������� 385
Exercises����������������������������������������������������������������������������������������������������������������������������������� 385

Chapter 53: Mailing Lists�������������������������������������������������������������������������������������� 387


Objectives��������������������������������������������������������������������������������������������������������������������������������� 387
Introduction������������������������������������������������������������������������������������������������������������������������������� 387

xii
Table of Contents

Installing Sympa����������������������������������������������������������������������������������������������������������������������� 388


About Sympa Documentation��������������������������������������������������������������������������������������������������� 389
Sympa Configuration and Integration��������������������������������������������������������������������������������������� 390
Getting Started with a New List������������������������������������������������������������������������������������������������ 398
Creating a Mailing List��������������������������������������������������������������������������������������������������������� 398
Testing the List�������������������������������������������������������������������������������������������������������������������� 403
Global and Local Settings��������������������������������������������������������������������������������������������������������� 404
Startup Problems���������������������������������������������������������������������������������������������������������������������� 405
Rejections from Large Email Services�������������������������������������������������������������������������������������� 406
Chapter Summary��������������������������������������������������������������������������������������������������������������������� 407
Exercises����������������������������������������������������������������������������������������������������������������������������������� 407

Chapter 54: Remote Desktop Access�������������������������������������������������������������������� 409


Objectives��������������������������������������������������������������������������������������������������������������������������������� 409
Introduction������������������������������������������������������������������������������������������������������������������������������� 409
TigerVNC����������������������������������������������������������������������������������������������������������������������������������� 410
Security������������������������������������������������������������������������������������������������������������������������������������� 418
Chapter Summary��������������������������������������������������������������������������������������������������������������������� 420
Exercises����������������������������������������������������������������������������������������������������������������������������������� 421

Chapter 55: Advanced Package Management������������������������������������������������������ 423


Objectives��������������������������������������������������������������������������������������������������������������������������������� 423
Introduction������������������������������������������������������������������������������������������������������������������������������� 423
Preparation������������������������������������������������������������������������������������������������������������������������������� 425
Examining the Spec File������������������������������������������������������������������������������������������������������������ 428
Preamble����������������������������������������������������������������������������������������������������������������������������� 429
%description����������������������������������������������������������������������������������������������������������������������� 431
%prep���������������������������������������������������������������������������������������������������������������������������������� 431
%files����������������������������������������������������������������������������������������������������������������������������������� 432
%pre������������������������������������������������������������������������������������������������������������������������������������ 432
%post���������������������������������������������������������������������������������������������������������������������������������� 432
%postun������������������������������������������������������������������������������������������������������������������������������ 433

xiii
Table of Contents

%clean��������������������������������������������������������������������������������������������������������������������������������� 434
%changelog������������������������������������������������������������������������������������������������������������������������� 434
Building the RPM���������������������������������������������������������������������������������������������������������������������� 434
Testing the RPM������������������������������������������������������������������������������������������������������������������������ 437
Rebuilding a Corrupted RPM Database������������������������������������������������������������������������������������� 438
Chapter Summary��������������������������������������������������������������������������������������������������������������������� 439
Exercises����������������������������������������������������������������������������������������������������������������������������������� 439

Chapter 56: File Sharing��������������������������������������������������������������������������������������� 441


Objectives��������������������������������������������������������������������������������������������������������������������������������� 441
Introduction������������������������������������������������������������������������������������������������������������������������������� 441
Preparation������������������������������������������������������������������������������������������������������������������������������� 443
Firewall Considerations������������������������������������������������������������������������������������������������������������� 445
Firewall Configuration for FTP��������������������������������������������������������������������������������������������� 446
FTP and FTPS���������������������������������������������������������������������������������������������������������������������������� 448
VSFTP���������������������������������������������������������������������������������������������������������������������������������������� 449
Installation and Preparation of VSFTP��������������������������������������������������������������������������������� 449
The FTP Client��������������������������������������������������������������������������������������������������������������������� 451
Anonymous FTP Access������������������������������������������������������������������������������������������������������� 454
Securing VSFTP with Encryption����������������������������������������������������������������������������������������� 455
NFS������������������������������������������������������������������������������������������������������������������������������������������� 458
NFS Server�������������������������������������������������������������������������������������������������������������������������� 458
NFS Client���������������������������������������������������������������������������������������������������������������������������� 460
Cleanup������������������������������������������������������������������������������������������������������������������������������� 462
SAMBA�������������������������������������������������������������������������������������������������������������������������������������� 462
Using the SAMBA Client������������������������������������������������������������������������������������������������������� 468
Midnight Commander��������������������������������������������������������������������������������������������������������������� 469
Apache Web Server������������������������������������������������������������������������������������������������������������������� 472
Chapter Summary��������������������������������������������������������������������������������������������������������������������� 477
Exercises����������������������������������������������������������������������������������������������������������������������������������� 478

xiv
Table of Contents

Chapter 57: Where Do I Go from Here?����������������������������������������������������������������� 481


Introduction������������������������������������������������������������������������������������������������������������������������������� 481
Curiosity������������������������������������������������������������������������������������������������������������������������������������ 481
Convert�������������������������������������������������������������������������������������������������������������������������������������� 482
Tools������������������������������������������������������������������������������������������������������������������������������������������ 483
Resources��������������������������������������������������������������������������������������������������������������������������������� 484
Contribute��������������������������������������������������������������������������������������������������������������������������������� 485
Teaching������������������������������������������������������������������������������������������������������������������������������ 485
Writing��������������������������������������������������������������������������������������������������������������������������������� 486
Coding and Packaging��������������������������������������������������������������������������������������������������������� 486
Donate $$���������������������������������������������������������������������������������������������������������������������������� 487
Skip This����������������������������������������������������������������������������������������������������������������������������������� 487
Compiling the Kernel����������������������������������������������������������������������������������������������������������� 487
Chapter Summary��������������������������������������������������������������������������������������������������������������������� 488

Bibliography��������������������������������������������������������������������������������������������������������� 491

Index��������������������������������������������������������������������������������������������������������������������� 501

xv
About the Author
David Both is an open source software and GNU/Linux
advocate, trainer, writer, and speaker. He has been working
with Linux and open source software for more than 25 years
and has been working with computers for over 50 years.
He is a strong proponent of and evangelist for the "Linux
Philosophy for System Administrators."
He worked for IBM for 21 years and, while working as
a course development representative in Boca Raton, FL, in
1981, wrote the training course for the first IBM PC. He has
taught RHCE classes for Red Hat and has taught classes on
Linux ranging from Lunch'n'Learns to full five-day courses.
David’s books and articles are a continuation of his desire to pass on his knowledge
and to provide mentoring to anyone interested in learning about Linux.
David prefers to purchase the components and build his own computers from
scratch to ensure that each new computer meets his exacting specifications. Building
his own computers also means not having to pay the Microsoft tax. His latest build is an
ASUS TUF X299 motherboard and an Intel i9 CPU with 16 cores (32 CPUs) and 64GB of
RAM in a Cooler Master MasterFrame 700.
David is the author of The Linux Philosophy for SysAdmins (Apress, 2018) and
co-author of Linux for Small Business Owners (Apress, 2022) and can be found on
Mastodon @linuxgeek46@LinoxRocks.online.

xvii
About the Technical Reviewers
Branton Brodie started his Linux journey last year while
attending All Things Open 2022. Getting into the IT world
was something he wanted to do for a while but didn’t
know where to start until he went there and saw all the
opportunities shown. Linux stood out to him the most, and
he is now studying to become a SysAdmin. He enjoys reading
about tech and how the future of tech will shape the world
around us. He lives in the calming town of Wake Forest, NC.

Seth Kenlon is a Unix and Linux geek, SysAdmin, open


source and free culture advocate, music producer, Java and
Lua programmer, game designer, and tabletop gamer. He
arrived in the computer industry by way of film production.

xix
Acknowledgments
Writing a book – and especially a three-volume second edition – is not a solitary activity,
and this massive Linux training course required a team effort much more so than most.
The most important person in this effort has been my awesome wife, Alice, who
has been my head cheerleader and best friend throughout. I could not have done this
without your support and love. Again!
I owe many thanks to my editors at Apress, James Robinson-Prior and Gryffin
Winkler, for seeing the need for a second edition and especially for being supportive as
I worked my way through some major restructuring and a significant amount of new
material. I especially thank you for your immediate support when I suggested having a
student as second technical editor.
Seth Kenlon, my amazing technical reviewer, and I have worked together before on
previous books as well as many of the articles I wrote for the now defunct Opensource.
com website. I am grateful for his contributions to the technical accuracy of all three
volumes of this course. Seth also made some important suggestions that improved
the flow and accuracy of this course. I once said that Seth was on the “ragged edge of
being brutally honest” in his editorial tasks; he responded that he had been aiming for
“completely brutal,” but had apparently failed. You still have my ongoing gratitude for the
work you do.
I also owe many thanks to Branton Brodie, my second technical editor for all three
volumes. Branton and I met as part of his desire to learn about Linux at a time when I
was just starting on this second edition. I thought that having a student who wanted to
take the course anyway act as a technical editor could provide me with some insight into
how students view the course. His contributions have been valuable to my work as I was
able to revise descriptions and explanations that made sense to me but not necessarily to
anyone who has never been exposed to Linux or system administration.
Of course any remaining errors, omissions, and poor explanations are my
responsibility alone.

xxi
Introduction
This Linux training course, “Using and Administering Linux – Zero to SysAdmin,” is
significantly different from other courses. It consists of three volumes. Each of these
three volumes is closely connected, and they build upon each other.
This Linux training course differs from others because it is a complete self-study
course. You should start at the beginning of Volume 1 and read the text, perform all of
the experiments, and do all of the chapter exercises through to the end of Volume 3. If
you do this, even if you are starting from zero knowledge about Linux, you can learn the
tasks necessary to becoming a Linux system administrator, a SysAdmin.
Another difference this course has over others is that all of the experiments are
performed on one or more virtual machines (VMs) in a virtual network. Using the free
software VirtualBox, you will create this virtual environment on any reasonably sized
host, whether Linux or Windows. In this virtual environment, you are free to experiment
on your own, make mistakes that could damage the Linux installation of a hardware
host, and still be able to recover completely by restoring the Linux VM host from any one
of multiple snapshots. This flexibility to take risks and yet recover easily makes it possible
to learn more than would otherwise be possible.
These course materials can also be used as reference materials. I have used my
previous course materials for reference for many years, and they have been very useful in
that role. I have kept this as one of my goals in this set of materials.
Not all of the review exercises in this course can be answered by simply reviewing
the chapter content. For some questions you will need to design your own experiment
in order to find a solution. In many cases there will very probably be multiple solutions,
and all that produce the correct results will be the “correct” ones.

The Process
The process that goes with this format is just as important as the format of the course –
really even more so. The first thing that a course developer must do is generate a list of
requirements that define both the structure and the content of the course. Only then can

xxiii
Introduction

the process of writing the course proceed. In fact, many times I find it helpful to write the
review questions and exercises before I create the rest of the content. In many chapters
of this course, I have worked in this manner.
These courses present a complete, end-to-end Linux training course for students
like you who know before you start that you want to learn to be a Linux system
administrator – a SysAdmin. This Linux course will allow you to learn Linux right from
the beginning with the objective of becoming a SysAdmin.
Many Linux training courses begin with the assumption that the first course a
student should take is one designed to start them as a user. Those courses may discuss
the role of root in system administration, but ignore topics that are important to future
SysAdmins. Other courses ignore system administration altogether. A typical second
course will introduce the student to system administration, while a third may tackle
advanced administration topics.
Frankly, this baby step approach did not work well for many of us who are now
Linux SysAdmins. We became SysAdmins, in part at least, due to our intense desire to
learn as much as possible as quickly as possible. It is also, I think in large part, due to our
highly inquisitive natures. We learn a basic command and then start asking questions,
experimenting with it to see what its limits are, what breaks it, what using it can break.
We explore the man(ual) pages and other documentation to learn the extreme usages to
which it might be put. If things don’t break by themselves, we break them intentionally
to see how they work and to learn how to fix them. We relish our own failures because
we learn more from fixing them than we do when things always work as they are
supposed to.
In this course we will dive deep into Linux system administration almost from the
very beginning. You will learn many of the Linux tools required to use and administer
Linux workstations and servers – usually multiple tools that can be applied to each of
these tasks. This course contains many experiments to provide you with the kind of
hands-on experiences that SysAdmins appreciate. All of these experiments guide you
one step at a time into the elegant and beautiful depths of the Linux experience. You
will learn that Linux is simple and that simplicity is what makes it both elegant and
knowable.
Based on my own years working with Unix and Linux, the course materials contained
in these three volumes are designed to introduce you to the practical, daily tasks you
will perform as a Linux user and, at the same time, as a Linux system administrator –
SysAdmin.

xxiv
Introduction

But I don’t know everything – that’s just not possible. No SysAdmin does. Further,
no two SysAdmins know exactly the same things because that, too, is impossible.
We have each started with different knowledge and skills; we have different goals;
we have different experiences because the systems on which we work have failed in
different ways, had different hardware, were embedded in different networks, had
different distributions installed, and many other differences. We use different tools and
approaches to problem solving because the many different mentors and teachers we
had used different sets of tools from each other; we use different Linux distributions; we
think differently; and we know different things about the hardware on which Linux runs.
Our past is much of what makes us what we are and what defines us as SysAdmins.
So I will show you things in this course – things that I think are important for you
to know, things that, in my opinion, will provide you with the skills to use your own
curiosity and creativity to find solutions that I would never think of to problems I have
never encountered.
I have always found that I learn more from my mistakes than I ever have when things
work as they are supposed to. For this reason I suggest that, rather than immediately
reverting to an earlier snapshot when you run into trouble, you try to figure out how the
problem was created and how best to recover from it. If, after a reasonable period of
time, you have not resolved the problem, that would be the point at which reverting to a
snapshot would make sense.

What This Course Is Not


This course is not a certification study guide. It is not designed to help you pass a
certification test of any type. This course is intended purely to help you become a good
or perhaps even great SysAdmin, not to pass a test.
There are a few good certification tests. Red Hat and Cisco certifications are among
the best because they are based on the test-taker’s ability to perform specific tasks. I am
not familiar with any of the other certification tests because I have not taken them. But
the courses you can take and books you can purchase to help you pass those tests are
designed to help you pass the tests and not to administer a Linux host or network. That
does not make them bad – just different from this course.

xxv
Introduction

Content Overview
This quick overview of the contents of each volume should serve as a quick orientation
guide if you need to locate specific information. If you are trying to decide whether to
purchase this book and its companion volumes, it will give you a good overview of the
entire course.

 sing and Administering Linux: Volume 1 – Zero to


U
SysAdmin: Getting Started
Chapters 1 through 3 of Volume 1 introduce operating systems in general and Linux in
particular and briefly explore the Linux Philosophy for SysAdmins in preparation for the
rest of the course.
Chapter 4 then guides you through the use of VirtualBox to create a virtual machine
(VM) and a virtual network to use as a test laboratory for performing the many
experiments that are used throughout the course. In Chapter 5, you will install the Xfce
version of Fedora – a popular and powerful Linux distribution – on the VM. Chapter 6
shows you how to use the Xfce desktop, which will enable you to leverage your growing
command-line interface (CLI) expertise as you proceed through the course.
Chapters 7 and 8 will get you started using the Linux command line and introduce
you to some of the basic Linux commands and their capabilities. In Chapter 9 you
will learn about data streams and the Linux tools used to manipulate them. And in
Chapter 10 you will learn a bit about several text editors, which are indispensable to
advanced Linux users and system administrators. You will also learn to use the Vim
text editor to create and modify the many ASCII plain text files that Linux uses for
configuration and administrative programming.
Chapters 11 through 13 start your work as a SysAdmin and take you through some
specific tasks such as working as root and installing software updates and new software.
Chapters 14 and 15 discuss more terminal emulators and some advanced shell skills. In
Chapter 16 you will learn about the sequence of events that take place as the computer
boots and Linux starts up. Chapter 17 shows you how to configure your shell to
personalize it in ways that can seriously enhance your command-line efficiency.
Finally, Chapters 18 and 19 dive into all things files and filesystems.

1. Introduction

2. Introduction to Operating Systems


xxvi
Introduction

3. The Linux Philosophy for SysAdmins

4. Preparation

5. Installing Linux

6. Using the Xfce Desktop

7. Using the Linux Command Line

8. Core Utilities

9. Data Streams

10. Text Editors

11. Working As Root

12. Installing and Updating New Software

13. Tools for Problem Solving

14. Terminal Emulator Mania

15. Advanced Shell Topics

16. Linux Boot and Startup

17. Shell Configuration

18. Files, Directories, and Links

19. Filesystems

 sing and Administering Linux: Volume 2 – Zero to


U
SysAdmin: Advanced Topics
Volume 2 of Using and Administering Linux introduces you to some incredibly powerful
and useful advanced topics that every SysAdmin must know.
In Chapters 20 and 21, you will experience an in-depth exploration of logical volume
management (LVM) – and what that even means – as well as the use of file managers
to manipulate files and directories. Chapter 22 introduces the concept that, in Linux,
everything is a file. You will also learn some fun and interesting uses of the fact that
everything is a file.

xxvii
Introduction

In Chapter 23 you will learn to use several tools that enable the SysAdmin to manage
and monitor running processes. Chapter 24 enables you to experience the power of the
special filesystems, such as /proc, which enable us as SysAdmins to monitor and tune
the kernel while it is running – without a reboot.
Chapter 25 will introduce you to regular expressions and the power that using
them for pattern matching can bring to the command line, while Chapter 26 discusses
managing printers and printing from the command line. In Chapter 27 you will use
several tools to unlock the secrets of the hardware on which your Linux operating system
is running.
Chapters 28 and 29 show you how to do some simple – and not so simple –
command-line programming and how to automate various administrative tasks. In
Chapter 30 you will learn to use Ansible, a powerful tool that makes automating tasks for
thousands of computers just as easy as for one. Chapter 31 discusses the tools you will
use to perform repetitive and automated tasks at specific times.
You will begin to learn the details of networking in Chapter 32, and Chapter 33 covers
use of the powerful NetworkManager tool.
Chapter 34 introduces the B-Tree Filesystem (BTRFS) and covers its very interesting
features. This chapter also informs you why BTRFS is not an appropriate choice for a
filesystem in most use cases.
Chapters 35 through 37 allow you to explore systemd, the modern tool for starting
Linux at boot time and which is also used to manage system services and tools.
Chapter 38 discusses D-Bus and udev and how Linux uses them to treat all devices as
plug and play (PnP).
In Chapter 39 you will learn to use and manage traditional log files. You will also
learn to configure and use the logwatch facility to assist you with sorting through the
many log messages to get to the important ones.
Chapter 40 covers the tasks required to manage users, while Chapter 41 introduces
you to some basic tasks needed to manage the firewall. You will use the firewalld
command-line tool to create and manage zones to which the network interfaces will be
assigned based on various security needs such as internal and external networks.

20. Logical Volume Management (LVM)


21. File Managers

22. Everything Is a File

23. Managing Processes

xxviii
Introduction

24. Special Filesystems


25. Regular Expressions
26. Printing
27. Hardware Detection
28. Command-Line Programming
29. Automation with Bash Scripts
30. Automation with Ansible
31. Time and Automation
32. Networking
33. NetworkManager
34. BTRFS
35. Getting Started with systemd
36. Advanced systemd Functions
37. systemd Finale
38. D-Bus and udev
39. Using Traditional Logs
40. Managing Users
41. Managing the Firewall

 sing and Administering Linux: Volume 3 – Zero to


U
SysAdmin: Network Services
In Volume 3 of Using and Administering Linux, you will start by creating a new VM in the
existing virtual network. This new VM will be used as a server for the rest of this course,
and it will replace some of the functions performed by the virtual router that is part of
our virtual network.
Chapter 42 begins this transformation from simple workstation to server by adding
a second network interface card (NIC) to the new VM so that it can act as a firewall and
router and then changing its network configuration from Dynamic Host Configuration
Protocol (DHCP) to static IP addressing. This includes configuring both NICs so that one
xxix
Introduction

is connected to the existing virtual router so as to allow connections to the outside world
and so that the other NIC connects to the new “inside” network that will contain the
existing VM.
Chapter 43 discusses Domain Name Services (DNS) in detail both from client and
server standpoints. You’ll learn to use the /etc/hosts file for simple name resolution and
then create a simple caching name server. You will then convert the caching name server
into a primary name server for your internal network.
In Chapter 44 you will convert the new server into a router using kernel parameters
and a simple firewall configuration change.
Chapter 45 shows how to use SSHD to provide secure remote access between Linux
hosts. It also provides some interesting insights into using commands remotely and
creating a simple command-line program to back up specific directories of a remote host
to the local host.
Although we have incorporated security in all aspects of what has already been
covered, Chapter 46 covers some additional security topics. This includes physical
hardening as well as further hardening of the host to provide enhanced protection from
network intrusions.
In Chapter 47 you will learn techniques and strategies for creating backups that use
easily available open source tools, which are easy to use for both creating backups and
restoring complete filesystems or individual files.
You will learn to install and configure an enterprise-class email server that can detect
and block most spam and malware in Chapters 48 through 50. Chapter 51 takes you
through setting up a web server, and in Chapter 52 you will set up WordPress, a flexible
and powerful content management system.
In Chapter 53 you return to email by setting up a mailing list using Mailman.
Sometimes accessing a desktop remotely is the only way to do some things, so in
Chapter 54 you will do just that.
Chapter 55 discusses package management from the other direction by guiding you
through the process of creating an RPM package for the distribution of your own scripts
and configuration files. Then Chapter 56 guides you through sharing files to both Linux
and Windows hosts.
Finally, Chapter 57 will get you started in the right direction because I know you are
going to ask, “Where do I go from here?”

42. Server Preparation

43. Name Services

xxx
Introduction

44. Routing

45. Remote Access with SSH

46. Security

47. Back Up Everything – Frequently

48. Introducing Email

49. Advanced Email Topics

50. Combating Spam

51. Apache Web Server

52. WordPress

53. Mailing Lists

54. Remote Desktop Access

55. Advanced Package Management

56. File Sharing

57. Where Do I Go from Here?

Taking This Course


Although designed primarily as a self-study guide, this course can be used effectively in
a classroom environment. This course can also be used very effectively as a reference.
Many of the original course materials I wrote for Linux training classes I used to teach
as an independent trainer and consultant were valuable to me as references. The
experiments became models for performing many tasks and later became the basis for
automating many of those same tasks. I have used many of those original experiments in
parts of this course, because they are still relevant and provide an excellent reference for
many of the tasks I still need to do.
You will see as you proceed through the course that it uses many software programs
considered to be older and perhaps obsolete like Sendmail, Procmail, BIND, the Apache
web server, and much more. Despite their age, or perhaps because of it, the software I
have chosen to run my own systems and servers and to use in this course has been well-
proven and is all still in widespread use. I believe that the software we will use in these

xxxi
Introduction

experiments has properties that make it especially valuable in learning the in-
depth details of how Linux and those services work. Once you have learned those details,
moving to any other software that performs the same tasks will be relatively easy. In any
event, none of that “older” software is anywhere near as difficult or obscure as some
people seem to think that it is.

Who Should Take This Course


If you want to learn to be an advanced Linux user and even a SysAdmin, this course is for
you. Most SysAdmins have an extremely high level of curiosity and a deep-seated need
to learn Linux system administration. We like to take things apart and put them back
together again to learn how they work. We enjoy fixing things and are not hesitant about
diving in to fix the computer problems that our friends and co-workers bring us.
We want to know what happens when some computer hardware fails, so we might
save defective components such as motherboards, RAM, and storage devices. This
gives us defective components with which we can run tests. As I write this, I have a
known defective hard drive inserted in a hard drive docking station connected to my
primary workstation and have been using it to test failure scenarios that will appear in
this course.
Most importantly, we do all of this for fun and would continue to do so even if we
had no compelling vocational reason for doing so. Our intense curiosity about computer
hardware and Linux leads us to collect computers and software like others collect stamps
or antiques. Computers are our avocation – our hobby. Some people like boats, sports,
travel, coins, stamps, trains, or any of thousands of other things, and they pursue them
relentlessly as a hobby. For us – the true SysAdmins – that is what our computers are.
That does not mean we are not well-rounded and don’t do other things. I like to travel,
read, go to museums and concerts, and ride historical trains, and my stamp collection is
still there, waiting for me when I decide to take it up again.
In fact, the best SysAdmins, at least the ones I know, are all multifaceted. We are
involved in many different things, and I think that is due to our inexhaustible curiosity
about pretty much everything. So if you have an insatiable curiosity about Linux and
want to learn about it – regardless of your past experience or lack thereof – then this
course is most definitely for you.

xxxii
Introduction

Who Should Not Take This Course


If you do not have a strong desire to learn about how to use or administer Linux
systems, this course is not for you. If all you want – or need – to do is use a couple apps
on a Linux computer that someone has put on your desk, this course is not for you. If
you have no curiosity about what superpowers lie behind the GUI desktop, this course
is not for you.

Why This Course


Someone asked me why I wanted to write this course. My answer is simple – I want to
give back to the Linux community. I have had several amazing mentors over the span of
my career, and they taught me many things – things I find worth sharing with you along
with much that I have learned for myself.
This course – all three volumes of it – started its existence as the slide presentations
and lab projects for three Linux courses I created and taught. For a number of reasons, I
do not teach those classes anymore. However, I would still like to pass on my knowledge
and as many of the tips and tricks I have learned for the administration of Linux as
possible. I hope that with this course I can pass on at least some of the guidance and
mentoring that I was fortunate enough to have in my own career.

About Fedora Releases


The first edition of this self-study course was originally written for Fedora 29, and we are
now up to Fedora 38. As I have worked through the second edition of this course, I have
added new materials I thought appropriate and incorporated as many errata corrections
as possible.
Where it was necessary, I have also included revised graphics such as screenshots
used for illustrative purposes. In many cases the graphics for earlier releases of Fedora
are still applicable although the background images and some nonessential visual
elements have changed. In those cases I have retained the original graphics.

xxxiii
Introduction

I have only replaced older graphics with newer ones where necessary to ensure the
accuracy and clarity of the illustrated points. Some of the illustrations in this course are
from Fedora 29. If you are using later releases of Fedora, such as Fedora 37, 38, or later,
the background and other cosmetic elements may be different from Fedora 29.

xxxiv
CHAPTER 42

Server Preparation
Objectives
In this chapter you will

• Create a new VM on which to install Fedora to use as a server,


firewall, and router.

• Install the latest version of Fedora on the VM to be used as the server.

• Make a few configuration changes to ensure that the new VM will


provide a suitable base to use as a server.

• Set the hostname.

• Change the network configuration to static.

• Verify the virtual network connection between StudentVM1 and


StudentVM2, as well as between the VMs and the outside world.

• Define the purpose and functions of DHCP.


• List several of the many network configuration items that DHCP
can serve.

• Use DHCP to assign and manage static IP addresses for specific hosts
based on the MAC address.

• Configure Chrony for this host to be the Network Time Protocol


(NTP) server for the network.

1
© David Both 2023
D. Both, Using and Administering Linux: Volume 3, https://doi.org/10.1007/978-1-4842-9786-5_42
Chapter 42 Server Preparation

Overview
There are some preparatory tasks that need to be accomplished in order perform the
experiments in this third volume of Using and Administering Linux – Zero to SysAdmin.
Most lab environments use physical machines for training purposes, but in this
volume we use at least two Linux hosts in a local network in order to enable a realistic
environment for learning about being a SysAdmin.
As we have seen in the previous two volumes of this course, the use of multiple VMs
to create a virtual network on a single physical host provides a safe virtual computing
and network environment in which to learn by making mistakes.
In Volume 1, you created a VM and a custom virtual network and installed Fedora on
it to use in the many experiments encountered in the rest of the course. We now need to
create a new VM that we can use as a server for this volume of the course.
In this volume, Volume 3, of the course, I assume that you have completed the
previous two volumes. You will not be able to successfully perform the experiments in
this volume if you have not completed the first two volumes. This is for two reasons. First,
you will probably not have sufficient knowledge to do so, and second, the virtual network
and virtual machine created in Volume 1 and changed and modified throughout Volume
2 will not be available or configured correctly to work in this part of the course.

Creating the VM
We first need to create a new VM we will use as our server for the rest of this course and
then make some configuration changes. Create the new VM using the specifications
listed in Figure 42-1.

2
Chapter 42 Server Preparation

Figure 42-1. The specifications for the StudentVM2 virtual machine

Use the VirtualBox Manager to create a new VM using the preceding specifications. If
necessary you can review Chapter 5 in Volume 1 for details.

3
Chapter 42 Server Preparation

At this point the basic virtual machine has been created, but we need to make a few
changes to some of the configuration. Use the VirtualBox Manager Settings dialog for
StudentVM2 to make these changes:

1. Deselect the Floppy disk and then move it down the Boot Order
to below the Hard Disk.

2. If your physical host has 8G of RAM or more, increase the


amount of video memory to 128MB. It is neither necessary nor
recommended that you enable 2D or 3D video acceleration
because it is not needed for this course.

3. Select the Network settings page and, on the Adapter 1 tab, select
NAT Network in the Attached to: field. Because we have created
only one NAT network, the StudentNetwork, that network will be
selected for us. Click the little blue triangle next to Advanced to
view the rest of the configuration for this device. Do not change
anything else on this page.

The virtual machine is now configured and ready for us to install Linux.

Installing Linux
Now install the most recent Fedora Linux Xfce version on StudentVM2. The initial
configuration for both VMs is exactly the same with only one exception. The hostname
for the server VM, StudentVM2, should be studentvm2 in all lowercase.

EXPERIMENT 42-1: INSTALLING FEDORA ON THE SERVER

Using the VirtualBox Manager, insert the ISO image file, Fedora-Xfce-Live-x86_64-38-1.iso –
or whatever the current version of the Xfce live image happens to be – into the StudentVM2
virtual machine’s storage controller as the IDE secondary master. Then boot the VM and
proceed with the installation from the live image using the filesystem configuration shown in
Figure 42-2.

4
Chapter 42 Server Preparation

Figure 42-2. The disk partitions – filesystems – and their sizes

Tip When I clicked the “Install to Hard Drive” icon on the desktop, I got a
notification that it was an “untrusted application launcher.” It is safe to ignore this
warning and click the Launch Anyway button.

Be sure to use manual filesystem configuration during the installation. If you need a bit of
assistance, Volume 1, Chapter 5, of this course contains the details of how to do the complete
installation, including creating the filesystems. Just remember to use the correct hostname for
this second virtual machine, studentvm2.

Note that we do not initially allocate all of the space in the volume group. However, be sure to
create the /boot and biosboot partitions first and then – this is very important – after creating /
root, the first filesystem that is part of the LVM system, be sure to alter the configuration of the
volume group to use the option “As large as possible,” in order to include all of the remaining
space on the virtual hard drive in the logical volume. I also suggest changing the volume group
name to vg01 to remove the reference to “live.”

5
Chapter 42 Server Preparation

It is no longer necessary to allocate swap space on the storage drive since Fedora now uses
8GB of Zram for swap space.

Important Be sure to modify the volume group so that it takes up all of the
remaining space on the virtual hard drive after creation of the /boot partition.
Be sure to set the root password and create a non-root user with the name of
“student” and set a password for that user before you click the Start Installation
button. Also, add a check mark to the box labeled “Allow root SSH login with
password.”

After the Fedora installation has completed, remove the live USB image from the IDE controller
and reboot StudentVM2 to verify that it comes up, runs properly, and can ping example.com
and StudentVM1.

Personalization and Updates


By this time in this course, you should have enough experience to have some favorite
tools that you like to use. I suggest that you take some time right now to install your
favorite command-line and desktop tools and personalize StudentVM2.

EXPERIMENT 42-2: PERSONALIZE AND UPDATE THE SERVER

As the root user on StudentVM2, configure the kernel so that it displays all kernel and startup
messages. If you need some guidance with this, we did it for StudentVM1 in Volume 1,
Chapter 16.

Next, install all current updates. We covered that in Chapter 12, so you may want to go back
and refresh your memory.

Perform any additional personalization that you want to both the student and root accounts.
This can include setting Bash configuration, installing tools that aren’t by default, and more.

6
Chapter 42 Server Preparation

Virtual Network Configuration


Using DHCP for network configuration in a traditional environment is good for some
hosts, but not for servers. Servers need to set their own network configuration; relying on
DHCP can cause changing IP addresses and possibly other information that might lead
to the inability of other hosts to find the servers in the network. In a cloud environment,
the provider will assign addresses, and you may not be able to depend upon a specific IP
address. In this chapter we will use the traditional approach of using static IP addresses
in which we have control over all aspects of our environment.
The initial virtual network we have configured for this course provides a virtual
router with a DHCP server. So long as we use the virtual DHCP server that is a part of the
virtual router, our new server will not receive a static IP address. So we need to change
the network configuration of StudentVM2 from DHCP to static.
The objective is for our server, StudentVM2, to become the DHCP server for our new
internal virtual network. One underlying reason for this is that the simple DHCP server
in the virtual router is not capable of handling some of the configuration settings we
will need later on. The other reason is so that you can get some experience with using
DHCP. This will also lay the groundwork for installing other services on our server so that
we can explore them more fully.
The virtual router provided by VirtualBox when we created StudentVM1 in Volume 1
of this course provides us with the 10.0.2.0/24 address range by default. Now we need an
internal virtual network for the internal clients like StudentVM1. The “internal” network
is usually called a local network because it is intended to be separate and distinct from
the Internet or other networks to which it is connected.
We first create a new “host-only” network and then a new virtual interface card
on StudentVM2. A “host-only” network in VirtualBox is one in which the hosts in the
network can only connect with each other and not directly to the outside world. The
hosts in this network will need a router to access the Internet at large; we will provide
that function as we move through this part of the course.

7
Chapter 42 Server Preparation

EXPERIMENT 42-3: CREATE THE LOCAL NETWORK

Use the VirtualBox Manager to create a new network that will be our local network. This is
actually quite simple because most of the data is entered by default.

Power down StudentVM2. At the top of the list of VMs, open the Tools ➤ Network dialog.
Click Host-only Networks and then the Create button to create a new host network.

The default is to configure the adapter manually, and the required data for IPV4 is already
generated and placed in the appropriate locations. Figure 42-3 shows the default
configuration for this adapter. There is no need to change anything on this tab.

Figure 42-3. The host network configuration

Be sure that the Enable Server box is not checked on the DHCP Server tab of the dialog. We
don’t want two DHCP servers in the network, and this one must be disabled. We will be using
vboxnet0 for this course because it is created automatically.

Figure 42-4 shows the completed dialog box, but the IPV6 data fields may be empty. If this is
the case, the Apply button will be grayed out.

1
Red Hat, Red Hat Enterprise Linux Networking Guide, https://access.redhat.com/
documentation/en-us/red_hat_enterprise_linux/7/html/networking_guide/
sec-configuring_ip_networking_with_nmcli

8
Chapter 42 Server Preparation

Figure 42-4. The host network configuration when creating the Virtual Machine

Click Apply – if it is highlighted – to finish creating the new network. Now we can add the new
NIC to StudentVM2 and connect it to this network.
Using the VirtualBox Manager, select StudentVM2, which should be powered off. If it is not,
do so now. Open the Settings dialog for StudentVM2 and select the Network tab. Click the
Adapter 2 tab and place a check mark in the Enable Network Adapter checkbox.

In the Attached to drop-down selection box, click Host-only Adapter. Because we have only
one network of this type, the vboxnet0 network is chosen by default. Click the little triangle-
shaped twistie next to Advanced and check out the rest of the configuration for this new NIC,
including the MAC address. Verify that there is a check mark in the Cable Connected box.

Click the OK button to complete the addition of this new virtual NIC.

9
Chapter 42 Server Preparation

Before we continue, we want to have a set of requirements that define the network
address map for our new, internal network. We should always create requirements before
starting a project of any kind. Figure 42-5 shows the range of network addresses we – well,
I, actually, but you get the idea – have arbitrarily decided upon for our very simple internal
network. It is typical for the router to have the “1” or another lowest IP address in the available
IP address range; however, the virtual network we just created assigns that IP address to its
own virtual router. So we will start with 192.168.56.11 for the local network router address.

Figure 42-5. The general address map for the virtual network as we want it to be
when we are finished

We have defined address ranges for workstations, servers, and even guest computers
such as what might be used in a flexible work environment. We will explore more about
assigning workstation and guest IP addresses in the “Overview of DHCP” section of this
chapter.
But before we can continue, we need to obtain some information about the NICs in
our VMs.

EXPERIMENT 42-4: GATHERING INTERFACE DATA

Perform this experiment as root. This experiment obtains the information we need to create
our address map. Remember that the MAC addresses will be different for your VMs than they
are for mine.

Power on StudentVM2. Log into StudentVM2, open a terminal session, and su - to root.

As the root user on StudentVM2, list the NICs installed in StudentVM2 and the associated MAC
and IP addresses. Remember that your MAC addresses will be different from mine and the IP
addresses – if any – will also be different:

10
Exploring the Variety of Random
Documents with Different Content
II.

To whisper in the rose’s ear


That all her beauty is no more;

III.

And bid her own the faith how vain,


Which Spring to her so lately swore.

IV.

A queen deposed, she quits her state;


The nightingales her fall deplore:

V.

The hundred-voicèd bird may woo


The thousand-leavèd flower no more.

VI.

The jasmine sinks its head in shame,


The sharp east wind its tresses shore;

VII.

And robbed in passing cruelly


The tulip of the crown it wore.

VIII.

The lil ’s s o d is b oken no


The lily’s sword is broken now,
That was so bright and keen before;

IX.

And not a blast can blow, but strews


With leaf of gold the earth’s dank floor.

X.

The piping winds sing Nature’s dirge


As through the forest bleak they roar,

XI.

Whose leafy screen, like locks of eld,


Each day shows scantier than before.

XII.

Thou fadest as a flower, O man!


Of food for musing here is store.

XIII.

O man! thou fallest as a leaf:


Pace thoughtfully earth’s leaf-strewn floor;

XIV.

Welcome the sadness of the time,


And lay to heart this natural lore.
MOSES AND JETHRO.
When Moses once on Horeb’s rocky steep,
A banished man, was keeping Jethro’s sheep,
What time his flocks along the hills and dells
Made music with their bleatings and their bells,
He by the thoughts that stirred within him, drawn
Deep in the mountain, heard at early dawn
One who in prayer did all his soul outpour,
With deep heart-earnestness, but nothing more.
For strange his words were, savage and uncouth,
And little did he know in very sooth
Of that great Lord, to whom his vows were made.
The other for a moment listening staid,
Until, his patience altogether spent—
“Good friend, for whom are these same noises meant?
For him, who dwells on high? this babbling vain,
Which vexes even a man’s ear with pain?
Oh, stop thy mouth—thou dost but heap up sin,
Such prayer as this can no acceptance win,
But were enough to make God’s blessings cease.”
Rebuked, the simple herdsman held his peace,
And only crying—“Thou hast rent my heart,”
He fled into the desert far apart:
While with himself, and with his zeal content,
His steps the Son of Amram homeward bent,
And ever to himself applauses lent—
Much wondering that he did not find the same
From his adopted sire, but rather blame,
Who having heard, replied—

“Was this well done?


What wouldst thou have to answer, O my son,
If God should say in anger unto thee—
‘Why hast thou driven my worshipper from me,
Why hast thou robbed me of my dues of prayer?
Well pleasing offering in my sight they were,
A d i i i if t i thi ’
And music in mine ears, if not in thine’—
He doth its bounds to every soul assign,
Its voice, its language—using which to tell
His praise, he counts that it doth praise him well;
And when there is a knocking at heaven’s gate,
And at its threshold many suppliants wait,
Then simple Love will often enter in,
While haughty Science may no entrance win.
Thus while his words were rougher husks than thine,
They yet might keep a kernel more divine,—
Rude vessel guarding a more precious wine.

“All prayer is childlike—falls as short of Him


The wisdom of the wisest Seraphim,
As the child’s small conceit of heavenly things;
A line to sound his depths no creature brings.
Before the Infinite, the One, the All,
Must every difference disappear and fall,
There is no wise nor simple, great nor small.
For him the little clod of common earth
Has to the diamond no inferior worth;
Nor doth the Ocean, world-encompassing,
Unto his thought more sense of vastness bring
Than tiny dew-drop—atoms in his eye
A sun, and a sun-mote, dance equally:
Not that the great (here understand aright)
Is worthless as the little in his sight,
Rather the little precious as the great,
And, pondered in his scales, of equal weight:
So that herein lies comfort—not despair,
As though we were too little for his care.

“God is so great, there can be nothing small


To him—so loving he embraces all,—
So wise, the wisdom and simplicity
Of man for him must on a level be:
But while all this more prompt to feel the wrong
But while all this, more prompt to feel the wrong,
And to resent it with displeasure strong,
When from him there is rudely, proudly turned
The meanest soul that loved him, and that yearned
After his grace—oh, haste then and begone,
Rebuild the altar thou hast overthrown;
Replace the offering which on that did stand,
Till rudely scattered by thy hasty hand—
Removing, if thou canst, what made it rise
A faulty and imperfect sacrifice.
And henceforth, in this gloomy world and dark,
Prize every taper yielding faintest spark,
And if perchance it burn not clear and bright,
Snuff, if thou canst, but do not quench it quite.”
PROVERBS
TURKISH AND PERSIAN.

I.
All skirts extended of thy mantle hold,
When angel hands from heav’n are scattering gold.

II.

Sects seventy-two, they say, the world infest,


And each and all lie hidden in thy breast.

III.

One staff of Moses, slight as it appears,


Aye breaks in shivers Pharaoh’s thousand spears.

IV.

Forget not Death, O man! for thou mayst be


Of one thing certain,—he forgets not thee.

V.

Speaks one of good which falls not to thy lot,


He also speaks of ill which thou hast not.

VI.

Boast not thy service rendered to the King,


’Tis grace enough he lets thee service bring.

VII.

Lies once thy cart in quagmire overthrown,


Thy path to thee by thousands will be shown.
yp y

VIII.

Oh square thyself for use—a stone that may


Fit in the wall, is left not in the way.

IX.

Never the game has happy issue won,


Which with the cotton has the fire begun.

X.

The world’s great wheel in silence circles round,


An housewife’s spindle with unceasing sound.

XI.

Who doth the raven for a guide invite,


Must marvel not on carcases to light.

XII.

The king but with one apple maketh free,


And straight his servants have cut down the tree.

XIII.

Two friends will in a needle’s eye repose,


But the whole world is narrow for two foes.

XIV.
Rejoice not when thine enemy doth die,
Thou hast not won immortal life thereby.

XV.

Be bold to bring forth fruit—though stick and stone


At the fruit-bearing trees are flung alone.

XVI.

All things that live from God their sustenance wait,


And sun and moon are beggars at his gate.

XVII.

While in thy lips thy words thou dost confine,


Thou art their lord—once uttered, they are thine.

XVIII.

Boldly thy bread upon the waters throw,


And if the fishes do not, God will know.

XIX.

What will not time and toil—? through these a worm


Will into silk a mulberry leaf transform.

XX.

When what thou willest has befall’n not, still


This help remains, what has befall’n to will.
p ,

XXI.

The lily with ten tongues can hold its peace;


Wilt thou with one from babbling never cease?

XXII.

How shall the praise of silence best be told?


To speak is silver, to hold peace is gold.

XXIII.

Thy word unspoken thou canst any day


Speak, but thy spoken ne’er again unsay.

XXIV.

O babbler, couldst thou but the cause divine


Why one tongue only, but two ears are thine!

XXV.

What mystic roses in thy breast will blow,


If on the wind their leaves thou straightway strow!
The good that one man flings aside
That in his discontent and pride
He treads on, and rejects no less.
Out of his count of happiness,
Another wiser, even from this
Would build an edifice of bliss,
For whose fair shelter he would pay
Glad offerings of praise alway.

This truth a Sage had need to learn—


This we may by his aid discern
Who once, reduced to last distress,
Was culling a few herbs to dress,
With these his hunger to allay;
And flinging, as he went his way,
The coarse and outer leaves aside,
With rising discontent he cried,
“I marvel if at all there be
A wretch so destitute as me
The wide world over.”—This he said,
And turning (not by chance) his head,
Behind him saw another sage,
Whom a like office did engage,
Who followed with weak steps behind,
Seeking, like him, a meal to find,
But who, with anxious quest and pain,
To gather up the leaves was fain,
By him rejected with disdain.

Nor other lesson he would teach,


The Poet in his Persian speech,
Who tells how through the desert he
Was toiling once, how painfully!
While his unsandalled naked feet
Were scorched and blistered by the heat
Of fiery sands and harsh and hard
Of fiery sands—and harsh and hard
He did his destiny regard;
And evil thoughts did in him stir,
That he, a faithful worshipper,
A pilgrim to God’s holy fane,
Should such necessities sustain.
Nor did a better mood succeed,
With glad endurance of his need,
Nor saw he what of sin was pent
In murmuring heart and malcontent,
Till entering a low chapel, there
One prostrate on his face in prayer
He marked, and unto him espied
Not shoes alone, but feet denied.
LOVE.

I.
Love is it, Love divine, that hath an impulse lent
To man, and beast, and worm, and every element.

II.

All riddles Love can solve, all mysteries unfold;


Ask what thou wilt, and Love the answer will present.

III.

I asked the circling heavens why they so swiftly moved:


Round Love’s eternal throne they ever wheeling went.

IV.

I asked the waves what made their murmurs never cease:


Shall we in Love’s great hymn with silence be content?

V.

I asked the bickering fire when it would climb no more:


When with the fire above in Love’s communion blent.

VI.

Night asked I why she hung the world with darkness round:
To consecrate the world for Love a bridal tent.

VII.

I asked the Westwind why it breathed so soft and warm:


All roses to unfold for Love the Westwind meant.
VIII.

I sought for some escape from the labyrinth of Love;


And found my bliss was there to be for ever pent.

IX.

O soul, that until now hast sullenly refused


Thy portion in Love’s joy, O sullen heart, relent;

X.

Oh! see Love’s mighty dance, oh! hear its choral hymn;
Stand up—in dance and hymn to take thy part consent.
THE FALCON.

I.
High didst thou once in honour stand,
The falcon on a Prince’s hand:

II.

Thine eye, unhooded and unsealed,


All depths of being pierced and scanned:

III.

All worlds of space, from end to end,


Thy never-wearied pinion spanned.

IV.

O falcon of the spiritual heaven—


Entangled in an earthly band,

V.

While all too eagerly thy prey


Pursuing in a lower land—

VI.

In hope abide;—thy Monarch yet


For thy release shall give command,

VII.

And bid thee to resume again


Thy place upon thy Monarch’s hand.
yp p y
LIFE THROUGH DEATH.

I.
A pagan King tormented fiercely all
Who would not on his senseless idols call,
Nor worship them:—and him were brought before,
A mother and her child, with many more.
The child, fast bound, was flung into the flame,
Her faith the mother did in fear disclaim:
But when she cried—“O sweetest! live as I,”
He answered—“Mother dear, I do not die;
Come, mother, bliss of heaven is here my gain,
Although I seem to you in fiery pain.
This fire serves only for your eyes to cheat,
Like Jesus’ breath of balm ’tis cool and sweet.
Come—learn what riches with our God are stored,
And how he feeds me at the angelic board.
Come, prove this fire—like water-floods it cools,
While your world’s water burns like sulphur pools.
Come—Abraham’s secret, when he found alone
Sweet roses in the furnace, here is known.
Into a world of death thou barest me,
O mother, death, not life, I owed to thee.
Fair world I deemed it once of glorious pride,
Till in this furnace I was deified;
But now I know it for a dungeon-tomb,
Since God has brought me into larger room.
Oh! now at length I live—from my pure heaven
Each cloud, that stained it once, away is driven:
Come, mother, come, and with thee many bring;
Cry, ‘Here is spread the banquet of the King;’
Come, all ye faithful—come, and dare to prove
The bitter-sweet, the pain and bliss of love.”

So cried the child unto that crowd of men;


All hearts with fiery longings kindled then;
Towàrd the pile they headlong rushing came,
And soon their souls fed sweetly on the flame.
II.

A dew-drop falling on the wild sea wave,


Exclaimed in fear—“I perish in this grave;”
But in a shell received, that drop of dew
Unto a pearl of marvellous beauty grew;
And, happy now, the grace did magnify
Which thrust it forth—as it had feared, to die;—
Until again, “I perish quite,” it said,
Torn by rude diver from its ocean bed:
O unbelieving!—so it came to gleam
Chief jewel in a Monarch’s diadem.

III.

The seed must die, before the corn appears


Out of the ground, in blade and fruitful ears.
Low must those ears by sickle’s edge be lain,
Ere thou canst treasure up the golden grain.
The grain is crushed, before the bread is made,
And the bread broke, ere life to man conveyed.
Oh! be content to die, to be laid low,
And to be crushed, and to be broken so;
If thou upon God’s table may’st be bread,
Life-giving food for souls an-hungerèd.
THE WORLD.

You might also like