UNIX
AND
LINUX'SYSTEM
ADMINISTRATION
HANDBOOK
FIFTH
EDITION
Evi Nemeth
Garth
Snyder
Trent R.
Hein
Ben
Whaley
Dan
Mackin
with
James Garnett,
Fabrizio Branca,
and Adrian Mouat
AAddison-Wesley
Boston•Columbus•
Indianapolis
•New York•San Francisco•Amsterdam•Cape
TownDubai•London•Madrid•Milan•Munich•Paris•Montreal•Toronto•Delhi•Mexico
City
Table
of Contents
Tribute
toEvi
xl
Preface
xlii
Foreword
xlivAcknowledgments
xlvi
SECTION ONE:
BASICADMINISTRATION
Chapter
1 WheretoStart 3Essential duties ofasystemadministrator 4
Controlling
access 4Adding
hardware 4Automating
tasks 4Overseeing backups
4Installing
andupgrading
software 5Monitoring
5Troubleshooting
5Maintaining
local documentation 5Vigilantly
monitoring security
6Tuning performance
6Developing
sitepolicies
6Working
with vendors 6 Firefighting
6Suggested background
7 Linuxdistributions 8Example
systemsusedinthis book 9Example
Linuxdistributions 10Example
UNIX distribution 11Notationand
typographical
conventions 12Units 13
Man pagesandother on-line documentation 14
Organization
of themanpages 14 man:readmanpages 15Storage
ofmanpages 15Other authoritativedocumentation 16
System-specific guides
16Package-specific
documentation 16Books 17
RFC
publications
17Othersourcesof information 18
Keeping
current 18HowTos and reference sites 19
Conferences 19
Ways
tofind andinstall software 19Determining
ifsoftwareisalready
installed 21Adding
newsoftware 22Building
softwarefromsourcecode 23Installing
fromawebscript
24Wheretohost 25
Specialization
andadjacent disciplines
26DevOps
26Site
reliability
engineers
27Security operations engineers
27Network administrators 27
Databaseadministrators 27
Network
operations
center(NOC) engineers
27Datacentertechnicians 28
Architects 28
Recommended
reading
28System
administrationandDevOps
28Table ofContents
_1
Chapter
2Booting
andSystem Management
Daemons
30Boot process overview 30
System
firmware 32BIOSvs. UEFI 32
Legacy
BIOS 33UEFI 33
Boot loaders 35
GRUB: the GRand Unified Boot loader 35
GRUB
configuration
36TheGRUB command line 37
Linuxkernel
options
38TheFreeBSDbootprocess 39
TheBIOS
path:
bootO 39The UEFI
path
39loader
configuration
40loadercommands 40
System
management daemons 41Responsibilities
ofinit 41Implementations
ofinit 42Traditional init 43
systemd
vs.the world 43 initsjudged
andassigned
theirproperpunishments
44systemd
in detail 44Units and unit files 45
systemctl:
managesystemd
46Unitstatuses 47
Targets
49Dependencies
among units 50Executionorder 51
Amore
complex
unitfileexample
52Localservicesandcustomizations 53 Serviceand
startup
controlcaveats 54systemd logging
56FreeBSDinitand
startup scripts
57 Reboot and shutdownprocedures
59Shutting
downphysical
systems 59Shutting
down cloudsystems
59Stratagems
foranonbooting
system 60Single-user
mode 61Single-user
modeonFreeBSD 62Single-user
mode withGRUB 62Chapter
3 AccessControl
andRootly
Powers65
Standard UNIXaccesscontrol 66
Filesystem
accesscontrol 66Process
ownership
67Theroot account 67
Setuid and
setgid
execution 68Management
of theroot account 69Rootaccount
login
69su:substituteuser
identity
70sudo: limitedsu 70
Example configuration
71sudo pros andcons 72 sudovs.advancedaccesscontrol 73
Typical
setup 74 Environmentmanagement
74sudo without
passwords
75Precedence 75
sudo withoutacontrol terminal 76
Site-wide sudo
configuration
76Disabling
theroot account 78System
accountsotherthanroot 78 Extensionstothe standardaccesscontrol model 79Drawbacks of the standard model 80
PAM:
Pluggable
Authentication Modules 80Kerberos: network
cryptographic
authentication 81Filesystem
accesscontrol lists 81Linux
capabilities
82Linux namespaces 82
Modernaccesscontrol 83
Separate
ecosystems 84Mandatory
accesscontrol 84Role-basedaccesscontrol 85
SELinux:
Security-Enhanced
Linux 85App
Armor 87Recommended
reading
89Chapter
4Process Control
90
Components
ofaprocess 90PID:processID number 91
PPID:parentPID 91
UID and EUID: real and effectiveuserID 92
GID and EGID: real and effectivegroupID 92
Niceness 93
Table of Contents
______
The life
cycle
ofaprocess 93Signals
94 kill: sendsignals
97 Processand threadstates 97 ps: monitor processes 98 Interactivemonitoring
with top 101 niceandrenice:influencescheduling
priority
102The
/proc
filesystem
104straceandtruss:trace
signals
and system calls 105Runaway
processes 107Periodicprocesses 109
cron: schedule commands 109
The format ofcrontabfiles 110 Crontab
management
112Other crontabs 112
cron accesscontrol 113
systemd
timers 113 Structureofsystemd
timers 114systemd
timerexample
114systemd
timeexpressions
116 Transient timers 117 Commonusesforscheduled tasks 118Sending
mail 118Cleaning
upafilesystem
118Rotating
alog
file 118Running
batchjobs
118Backing
up andmirroring
119Chapter
5 The
Filesystem
120 Pathnames 122Filesystem
mounting
andunmounting 122Organization
of the filetree 125File
types
126Regular
files 129Directories 129
Hard links 129
Character and block device files 130 Local domain sockets 131
Named
pipes
131File attributes 132 The
permission
bits 132 The setuid andsetgid
bits 133The
sticky
bit 134Is: list and
inspect
files 134 chmod:change
permissions
136 chown andchgrp:
change
ownership
and group 137 umask:assigndefaultpermissions
138 Linux bonusflags
139 Access control lists 140 Acautionary
note 141 ACLtypes 141Implementation
of ACLs 142 Linux ACLsupport 142 FreeBSD ACLsupport 143POSIX ACLs 143
Interaction between traditionalmodesand ACLs 144
POSIXaccessdetermination 146
POSIX ACLinheritance 146
NFSv4 ACLs 147
NFSv4 entitiesfor which
permissions
canbespecified
148NFSv4accessdetermination 149
ACLinheritancein NFSv4 149
NFSv4ACL
viewing
150 Interactions between ACLs and modes 151 NFSv4ACL setup 151Chapter
6Software Installation and
Management
153Operating
system installation 154Installing
from thenetwork 154Setting
up PXE 155Using kickstart,
the automatedinstaller for Red Hat and CentOS 156Setting
upakickstartconfiguration
file 156Building
akickstartserver 158Pointing
kickstartatyourconfig
file 158Automating
installation for Debian and Ubuntu 159Netbooting
withCobbler,the opensourceLinuxprovisioning
server 161Automating
FreeBSD installation 161Managing
packages
162 Linuxpackage
management
systems 164rpm: manage RPM
packages
164Table ofContents *!
High-level
Linuxpackage
management systems 166Package
repositories 167 RHN:theRed Hat Network 169 APT:the AdvancedPackage
Tool 169Repository configuration
170An
example
/etc/apt/sources.list
file 171Creationofalocal
repository
mirror 172APT automation 173
yum: release managementfor RPM 174 FreeBSD software management 175
The basesystem 175
pkg:
the FreeBSDpackage
manager 176Theports collection 177
Software localization and
configuration
178Organizing
yourlocalization 179Structuring updates
179Limiting
the field ofplay
180Testing
180Recommended
reading
181Chapter
7Scripting
and
the Shell 182Scripting
philosophy
183Writemicroscripts 183 Learnafew tools well 184 Automate all the
things
184Don't
optimize prematurely
185 Pick theright scripting language
186Followbest
practices
187Shellbasics 189
Command
editing
190Pipes
andredirection 190Variables and
quoting
192Environmentvariables 193
Common filter commands 194 cut:separatelinesintofields 194
sort: sortlines 194
uniq: print unique
lines 195wc:countlines, words,and characters 196
tee:copy
input
to twoplaces
196 head andtail: read thebeginning
orend ofafile 196sh
scripting
198Execution 198
Fromcommandsto
scripts
199Input
and output 201Spaces
infilenames 202Command-line arguments and functions 203
Control flow 205
Loops
207Arithmetic 209
Regular
expressions
209The
matching
process 210Literal characters 210
Special
characters 210Example regular
expressions
211Captures
213Greediness,
laziness, andcatastrophic backtracking
213Python
programming
215The
passion
ofPython
3 215Python
2orPython
3? 216Python quick
start 216Objects,
strings,
numbers, lists, dictionaries,tuples,
and files 218Input
validationexample
220Loops
221Ruby
programming
223Installation 223
Ruby quick
start 224Blocks 225
Symbols
andoption
hashes 227Regular
expressionsinRuby
227Ruby
as afilter 229Library
and environmentmanagementforPython
andRuby
229Finding
andinstalling
packages
229Creating
reproducible
environments 230Multiple
environments 231virtualenv: virtualenvironmentsfor
Python
232 RVM:theRuby
environmentManager
232 Revisioncontrol withGit 235A
simple
Gitexample
236Gitcaveats 239
Social
coding
with Git 239 Recommendedreading
241Shellsand shell
scripting
241Regular
expressions 241Python
242Table ofContents xiii
Chapter
8 UserManagement
243Account mechanics 244
The
/etc/passwd
file 245Login
name 245Encrypted password
246 UID(user
ID) number 248DefaultGID
(group
ID)number 249GECOS field 249
Home
directory
250Login
shell 250 The Linux/etc/shadow file 250 FreeBSD's/etc/master.passwd
and/etc/login.conf
files 252 The/etc/master.passwd
file 252The
/etc/login.conf
file 253The/etc/group
file 254 Manualstepsforadding
users 255Editing
thepasswd
andgroupfiles 256Setting
apassword
257Creating
the homedirectory
andinstalling
startupfiles 257Setting
homedirectory permissions
andownerships
259Configuring
roles and administrativeprivileges
259Finishing
up 260Scripts
foradding
users:useradd,
adduser,andnewusers 260useraddonLinux 261
adduseronDebian and Ubuntu 262
adduseronFreeBSD 262
newusersonLinux:
adding
inbulk 263Safe removal ofauser'saccountand files 264
User
login
lockout 265 Risk reduction with PAM 266 Centralizedaccountmanagement 266LDAP and Active
Directory
267Application-level
single
sign-on
systems 267Identity
management systems 268Chapter
9Cloud
Computing
270Thecloudincontext 271
Cloud
platform
choices 273Public,
private,
andhybrid
clouds 273 Amazon WebServices 274Cloudservicefundamentals 276
Accesstothe cloud 277
Regions
andavailability
zones 278Virtual
private
servers 279Networking
280Storage
281Identity
andauthorization 281Automation 282
Serverless functions 282
Clouds:VPS
quick
startby platform
283 AmazonWebServices 283aws:controlAWS
subsystems
284Creating
anEC2 instance 284Viewing
the consolelog
286Stopping
andterminating
instances 287Setting
upgcloud
288Running
aninstanceonGCE 288DigitalOcean
289Cost control 291
Recommended
Reading
293Chapter
10
Logging
294Log
locations 296 Filesnot tomanage 298Howtoview
logs
inthesystemd journal
298The
systemd journal
299Configuring
thesystemd journal
300Adding
morefiltering
options
forjournalctl
301Coexisting
withsyslog
301Syslog
302Reading syslog
messages 303Rsyslog
architecture 304Rsyslog
versions 304Rsyslog configuration
305 Modules 306sysklogd
syntax 307Legacy
directives 311RainerScript
312Config
fileexamples
314Basic
rsyslog configuration
314Network
logging
client 315Central
logging
host 316Syslog
messagesecurity
317Table of Contents
Kernel and boot-time
logging
318Management
androtationoflog
files 319logrotate:
cross-platform log
management 319newsyslog:
log
managementonFreeBSD 321Management
oflogs
atscale 321TheELK stack 321
Graylog
322Logging
as aservice 323Logging
policies
323Chapter
11Drivers and the
Kernel 325 Kernel chores forsystem
administrators 326Kernel version
numbering
327Linux kernel versions 327
FreeBSDkernelversions 328 Devicesand their drivers 328 Devicefilesand device numbers 329
Challenges
ofdevice filemanagement
330Manualcreationofdevicefiles 331 Moderndevice file management 331 Linux devicemanagement 331
Sysfs:
awindowintothesouls of devices 332udevadm:
explore
devices 333 Rules andpersistentnames 334FreeBSD device
management
337Devfs:automaticdevice file
configuration
337devd:
higher-level
devicemanagement 338Linuxkernel
configuration
339Tuning
Linux kernelparameters 339Building
acustomkernel 341Ifitain't
broke,
don't fixit 341Setting
uptobuildthe Linux kernel 341Configuring
kerneloptions
342Building
thekernelbinary
343Adding
aLinux device driver 344FreeBSD kernel
configuration
344Tuning
FreeBSD kernelparameters 344Building
aFreeBSD kernel 345Loadable kernelmodules 346
Loadable kernelmodules in Linux 346
Loadable kernel modulesin FreeBSD 348
Booting
348Linuxbootmessages 349
Booting
alternate kernels in the cloud 355Kernelerrors 356
Linux kernelerrors 356
FreeBSD kernel
panics
359 Recommendedreading
359Chapter
12Printing
360CUPS
printing
361Interfacesto the
printing system
361The
Multiple
printers
andqueues 363Printerinstances 363
Network
printer
browsing
363Filters 364
CUPSserveradministration 365
Network
setup
365Printer
autoconfiguration
366 Networkprinter
configuration
367 Printerconfiguration
examples
367Service shutoff 368
Other
configuration
tasks 368Troubleshooting
tips
369Print daemonrestart 369
Log
files 369Direct
printing
connections 370 Networkprinting
problems
370Recommended
reading
371SECTION TWO: NETWORKING
Chapter
13 TCP/IP
Networking
375 TCP/IPanditsrelationship
tothe Internet 375 Whorunsthe Internet? 376Network standards and documentation 376
Networking
basics 378IPv4 and IPv6 379
Packets and
encapsulation.
381Ethernet
framing
382 Maximumtransferunit 382Table of Contents
U
Packet
addressing
384 Hardware(MAC) addressing
384 IPaddressing
385 Hostname"addressing"
385Ports 385
Address types 386 IP addresses:thegorydetails 387 IPv4address classes 387
IPv4
subnetting
388Tricks and tools forsubnet arithmetic 390 CIDR: Classless Inter-Domain
Routing
391Addressallocation 392 Private addresses and network address translation
(NAT)
392IPv6
addressing
394IPv6 address notation 395 IPv6
prefixes
396Automatic host
numbering
397Stateless address
autoconfiguration
397IPv6
tunneling
398 IPv6 informationsources 398Routing
398Routing
tables 399ICMP redirects 401
IPv4 ARPandIPv6
neighbor discovery
401 DHCP:theDynamic
HostConfiguration
Protocol 402 DHCPsoftware 403 DHCP behavior 404 ISCsDHCP software 404Security
issues 406 IPforwarding
406 ICMP redirects 407 Sourcerouting 407Broadcast
pings
andother directed broadcasts 407 IPspoofing
408Host-based firewalls 408
Virtual
private
networks 409 Basicnetworkconfiguration
410 Hostname and IP addressassignment 411Networkinterface and IP
configuration
412Routing
configuration
414DNS
configuration
415Linux
networking
417NetworkManager
417ip:
manually configure
anetwork 418Debian and Ubuntu network
configuration
419Red Hat and CentOS network
configuration
419 Linux networkhardwareoptions
421 Linux TCP/IPoptions
422Security-related
kernel variables 424 FreeBSDnetworking
425ifconfig: configure
network interfaces 425 FreeBSD network hardwareconfiguration
426 FreeBSD boot-time networkconfiguration
426 FreeBSD TCP/IPconfiguration
427 Networktroubleshooting
428ping:
checktoseeifahost is alive 429traceroute: traceIP
packets
431Packet sniffers 434
tcpdump:
command-linepacket
sniffer 435WiresharkandTShark:
tcpdump
onsteroids 436Network
monitoring
437SmokePing: gather
ping
statisticsovertime 437iPerf: track network
performance
437 Cacti: collect andgraph
data 438Firewallsand NAT 440 Linux
iptables:
rules, chains, and tables 440iptables
ruletargets
441iptables
firewallsetup 442A
complete example
442LinuxNATand
packet filtering
444IPFilter for UNIXsystems 445
Cloud
networking
448AWS's virtual
private
cloud(VPC)
448 Subnets androuting
tables 449Security
groupsand NACLs 450A
sample
VPC architecture 451Creating
aVPC with Terraform 452networking
455DigitalOcean
networking
456 Recommendedreading
457History
457 Classicsand bibles 458Table of Contents
Chapter
14Physical Networking
459 Ethernet:the SwissArmy
knife ofnetworking
460 Ethernetsignaling
460 Ethernettopology
461 Unshieldedtwisted-pair cabling
462Optical
fiber 464Ethernet connectionand
expansion
465Hubs 465
Switches 465
VLAN-capable
switches 466Routers 467
Autonegotiation
467PoweroverEthernet 468
Jumbo
frames 468Wireless:Ethernet for nomads 469
Wireless standards 469
Wirelessclientaccess 470
Wirelessinfrastructure and WAPs 470
Wireless
topology
471 Small money wireless 472Big
money wireless 472 Wirelesssecurity
473 SDN:software-definednetworking
473 Networktesting
anddebugging
474Building wiring
475UTP
cabling
options
475Connectionstooffices 475
Wiring
standards 475Network
design
issues 476Networkarchitecturevs.
building
architecture 477Expansion
477Congestion
478Maintenanceand documentation 478
Management
issues 478 Recommended vendors 479 Cables andconnectors 479Test
equipment
480Routers/switches 480
Chapter
15
IP
Routing
481 Packetforwarding:
acloser look 482Routing
daemons androuting
protocols
485Distance-vector
protocols
486 Link-stateprotocols
487Cost metrics 487
Interior and exterior
protocols
488 Protocolsonparade
488 RIP andRIPng: Routing
Information Protocol 488 OSPF:Open
Shortest Path First 489 EIGRP:EnhancedInteriorGateway
Routing
Protocol 490 BGP: BorderGateway
Protocol 490Routing protocol
multicast coordination 490Routing
strategy selectioncriteria 490Routing
daemons 492routed: obsoleteRIP
implementation
492Quagga:
mainstreamrouting
daemon 493XORP:routerinabox 494
Ciscorouters 494
Recommended
reading
496Chapter
16
DNS: The Domain Name
System
498
DNS architecture 499
Queriesand responses 499 DNS service
providers
500DNSfor
lookups
500resolv.conf: clientresolver
configuration
500nsswitch.conf: who doIask foraname? 501
TheDNS namespace 502
Registering
adomainname 503Creating
yourownsubdomains 503HowDNSworks 503 Nameservers 504
Authoritative and
caching-only
servers 505Recursiveandnonrecursiveservers 505
Resource records 506
Delegation
506Caching
andefficiency
508Multiple
answersand round robin DNS loadbalancing
508Debugging
with query tools 509TheDNS database 512
Parser commands inzonefiles 512
Resource records 513
Table of Contents
x*i
NSrecords 518 Arecords 519 AAAArecords 519 PTRrecords 520 MXrecords 521 CNAME records 522 SRV records 523 TXT records 524SPF, DKIM,and DMARC records 525
DNSSEC records 525
The BIND software 525
Components
of BIND 525Configuration
files 526 The includestatement 527The optionsstatement 528
The acl statement 534
The
(TSIG)
keystatement 534The serverstatement 535
The mastersstatement 535 The loggingstatement 536
The statistics-channels statement 536
The zonestatement 536
Configuring
themasterserverfora zone 537Configuring
aslaveserverfora zone 538Setting
up therootserverhints 539Setting
upaforwarding
zone 539Thecontrols statementfor rndc 540
Split
DNS andtheviewstatement 541BIND
configuration
examples
543 Thelocalhostzone 543Asmall
security
company 544Zonefile
updating
547Zone transfers 548
Dynamic
updates
549 DNSsecurity
issues 551 Accesscontrol lists inBIND, revisited 552Open
resolvers 553Running
inachrootedjail
554Secureserver-to-servercommunication with TSIG and TKEY 554
Setting
up TSIGforBIND 555DNSSEC 557
DNSSEC
policy
558DNSSECresourcerecords 558
Turning
onDNSSEC 560Key pair generation
560Zone
signing
562TheDNSSECchain oftrust 564
DNSSEC
key
rollover 565DNSSEC tools 566
ldnstools,
nlnetlabs.nl/projects/ldns
566dnssec-tools.org
566RIPEtools,
ripe.net
567OpenDNSSEC,
opendnssec.org
567Debugging
DNSSEC 567 BINDdebugging
568Logging
in BIND 568 Channels 569Categories
570Log
messages 570Sample
BINDlogging configuration
573Debug
levelsinBIND 573Nameservercontrol withrndc 574
Command-line
querying
forlamedelegations
575Recommended
reading
576Booksandotherdocumentation 577
On-lineresources 577
TheRFCs 577
Chapter
17Single Sign-On
578Core SSO elements 579 LDAP:
"lightweight" directory
services 580UsesforLDAP 580
ThestructureofLDAPdata 581
OpenLDAP:
the traditionalopensourceLDAPserver 582389
Directory
Server: alternative opensourceLDAPserver 583LDAP
Querying
584Conversion of
passwd
andgroupfilestoLDAP 585Using
directory
servicesforlogin
586Kerberos 586
LinuxKerberos
configuration
for ADintegration
587FreeBSD Kerberos
configuration
for ADintegration
587sssd: the
System
Security
Services Daemon 589nsswitch.conf: thenameservice switch 590
PAM:
cooking
sprayorauthenticationwonder? 590PAM
configuration
591 PAMexample
592 Alternativeapproaches
594 NIS: the Network Information Service 594 rsync:transfer filessecurely
594Table of Contents
?*!!!
Chapter
18 Electronicsystem
architecture 597Useragents 597
Submissionagents 598
Transport
agents 598Local
delivery
agents 599Message
stores 599Accessagents 599
Anatomy
ofamailmessage 600TheSMTP
protocol
603YouhadmeatEHLO 604 SMTPerrorcodes 604
SMTPauthentication 604
Spam
andmalware 605Forgeries
606SPF and Sender ID 606
DKIM 607
Message privacy
andencryption
607Mail aliases 608
Getting
aliases fromfiles 610Mailing
tofiles 611Mailing
toprograms 611Building
thehashed alias database 612 Emailconfiguration
612sendmail 613
The switchfile 614
Starting
sendmail 615Mailqueues 616
sendmail
configuration
617Them4preprocessor 617
The sendmail
configuration pieces
618A
configuration
file built fromasample
.mcfile 619Configuration primitives
620 Tables anddatabases 620 Genericmacrosand features 6210STYPE macro 621
DOMAINmacro 621
MAILERmacro 622
FEATUREmacro 622
use_cw_file feature 622
redirectfeature 623
always_add_domain
feature 623access_db feature 623 virtusertable feature 624
ldap_routing feature 624
Masquerading
features 625MAIL_HUB and SMART_HOSTmacros 626
Client
configuration
626m4
configuration
options
627Spam-related
featuresinsendmail 628Relay
control 629Userorsite
blacklisting
630Throttles,
rates,andconnectionlimits 631Security
and sendmail 632Ownerships
633Permissions 634
Safer mailtofiles andprograms 634
Privacy options
635Running
achrooted sendmail(for
thetruly paranoid)
636Denial ofserviceattacks 636 TLS:
Transport Layer Security
637 sendmailtesting
anddebugging
638Queue monitoring
638Logging
639 Exim 640 Exim installation 640 Eximstartup
642 Exim utilities 642Exim
configuration language
643Exim
configuration
file 644Globaloptions 645
Options
645Lists 646
Macros 647
Access control lists
(ACLs)
647Content
scanning
atACLtime 650Authenticators 651
Routers 652
Theacceptrouter 653
The dnslookuprouter 653
Themanualrouterouter 653
Theredirectrouter 654 Per-user
filtering through
.forwardfiles 655Transports
655The appendfiletransport 655
The smtp transport 656
Retry
configuration
656Rewriting
configuration
657TableofContents **Y
Logging
657Debugging
658 Postfix 658 Postfix architecture 659Receiving
mail 659Managing
mail-waiting
queues 660Sending
mail 660Security
661Postfixcommands and documentation 661 Postfix
configuration
661Whattoputinmain.cf. 662
Basic
settings
662 Null client 662 Use ofpostconf
663Lookup
tables 663 Localdelivery
664 Virtual domains 665Virtual alias domains 666
Virtualmailboxdomains 667
Accesscontrol 667
Accesstables 669
Authenticationofclients and
encryption
670Debugging
670Looking
atthe queue 671Soft-bouncing
671 Recommendedreading
672 sendmail references 672 Exim references 672 Postfix references 672 RFCs 673Chapter
19 WebHosting
674HTTP: the
Hypertext
Transfer Protocol 674UniformResource Locators(URLs) 675 Structure ofanHTTP transaction 676
HTTPrequests 677
HTTP responses 677
Headers and themessage
body
678 curl: HTTP from the command line 679TCPconnectionreuse 680
HTTPoverTLS 681
Web softwarebasics 682
Webserversand HTTP proxy software 683
Load balancers 684
Caches 686
Browser caches 687
Proxy
cache 688 Reverse proxy cache 688Cache
problems
688Cachesoftware 689 Content
delivery
networks 689Languages
ofthe web 691Ruby
691Python
691 Java 691Node.js
691 PHP 692 Go 692Application
programming
interfaces(APIs)
692Web
hosting
inthe cloud 694Buildversus
buy
694Platform-as-a-Service 695
Staticcontent
hosting
695Serverless web
applications
696Apache httpd
696httpd
inuse 697httpd configuration logistics
698Virtual host
configuration
699 HTTP basic authentication 701Configuring
TLS 702Running
webapplications
withinApache
702Logging
703NGINX 704
Installing
andrunning
NGINX 704Configuring
NGINX 705Configuring
TLS for NGINX 708 Loadbalancing
with NGINX 708HAProxy
710 Health checks 711 Server statistics 712Sticky
sessions 712 TLS termination 713 Recommendedreading
714Table of Contents xxvii
SECTION THREE: STORAGE
Chapter
20
Storage
717I
just
want toaddadisk! 718Linux
recipe
719FreeBSD
recipe
720Storage
hardware 721Hard disks 722
Hard disk
reliability
723 Failure modes and metrics 723Drive
types
724Warranties andretirement 725 Solidstatedisks 725
Rewritability
limits 726 Flashmemoryand controllertypes
726Page
clusters andpre-erasing
727 SSDreliability
727Hybrid
drives 728AdvancedFormat and 4KiB blocks 729
Storage
hardware interfaces 730The SATA interface 730
ThePCI
Express
interface 730 TheSASinterface 731USB 732
Attachment and low-level
management
of drives 733 Installation verificationatthe hardware level 733 Disk device files 734Ephemeral
devicenames 735Formatting
andbad blockmanagement 735ATAsecure erase 737
hdparm
and camcontrol:setdisk and interface parameters 738Hard disk
monitoring
withSMART 738 Thesoftware side of storage:peeling
theonion 739 Elements ofastorage
system 740The Linuxdevice mapper 742 Disk
partitioning
742 Traditionalpartitioning
744MBR
partitioning
745GPT: GUID
partition
tables 746 Linuxpartitioning
746 FreeBSDpartitioning
747Logical
volumemanagement 747 Linuxlogical
volume management 748Volume
snapshots
750Filesystem
resizing
751FreeBSD
logical
volume management 753 RAID:redundantarraysofinexpensive
disks 753Softwarevs.hardwareRAID 753
RAID levels 754 Diskfailurerecovery 756 DrawbacksofRAID 5 757 mdadm: LinuxsoftwareRAID 758
Creating
anarray 758mdadm.conf: document array
configuration
760Simulating
afailure 761Filesystems
762Traditional
filesystems:
UFS,
ext4,and XFS 763Filesystem terminology
764Filesystem polymorphism
765Filesystem formatting
766fsck: checkand
repair
filesystems
766Filesystem
mounting
767Setup
forautomaticmounting
768USB drive
mounting
770Swapping
recommendations 770Next-generation
filesystems:
ZFSandBtrfs 772Copy-on-write
772Error detection 772
Performance 773
ZFS: all your
storage
problems
solved 773ZFSonLinux 774
ZFS architecture 774
Example:
disk addition 775Filesystems
andproperties 776Property
inheritance 777One
filesystem
peruser 778Snapshots
and clones 779Rawvolumes 780
Storage
pool
management 781Btrfs: "ZFS lite" forLinux 783
Btrfsvs. ZFS 783
Setup
and storageconversion 784Volumes and subvolumes 786
Volume
snapshots
787Table of Contents
Data
backup
strategy 788Recommended
reading
790Chapter
21The Network File
System
791
Meet network fileservices 791 The
competition
792Issuesofstate 792
Performanceconcerns 793
Security
793TheNFS
approach
794Protocolversionsand
history
794 Remoteprocedure
calls 795Transport
protocols
795State 796
Filesystem
exports 796File
locking
797Security
concerns 798Identity
mapping
in version 4 799Rootaccessand the
nobody
account 800Performanceconsiderations inversion 4 801
Server-side NFS 801
Linuxexports 802
FreeBSDexports 804
nfsd:servefiles 806
Client-sideNFS 807
Mounting
remotefilesystems
atboottime 810Restricting
exportstoprivileged
ports 810Identity
mapping
forNFS version4 810nfsstat:
dump
NFS statistics 811 Dedicated NFS fileservers 812 Automaticmounting
812 Indirect maps 814 Direct maps 814 Master maps 815 Executablemaps 815 Automountvisibility
816Replicated filesystems
andautomount 816Automaticautomounts
(V3;
all butLinux)
817Specifics
forLinux 817Chapter
22SMB
819Samba:SMBserverfor UNIX 820
Installing
andconfiguring
Samba 821File
sharing
withlocal authentication 822File
sharing
withaccountsauthenticatedby
ActiveDirectory
822Configuring
shares 823Sharing
home directories 823Sharing
project
directories 824Mounting
SMBfileshares 825Browsing
SMBfile shares 826Ensuring
Sambasecurity
826Debugging
Samba 827Querying
Sambasstatewithsmbstatus 827Configuring
Sambalogging
828Managing
charactersets 829Recommended
reading
829SECTION FOUR: OPERATIONS
Chapter
23Configuration Management
833
Configuration management
inanutshell 834Dangers
ofconfiguration management
834Elements of
configuration management
835Operations
andparameters 835Variables 837
Facts 838
Change
handlers 838Bindings
838Bundles and bundle
repositories
839Environments 839
Client
inventory
andregistration
840Popular
CMsystemscompared
841Terminology
842Businessmodels 842
Architectural
options
843Language options
845Dependency
management options
846GeneralcommentsonChef. 848
Generalcommentson
Puppet
849GeneralcommentsonAnsible andSalt 850
Table of Contents XXXI IntroductiontoAnsible 852 Ansible
example
853 Clientsetup 855 Client groups 857 Variableassignments
858Dynamic
andcomputed
clientgroups 859Tasklists 860
stateparameters 862
Iteration 862
Interaction with
Jinja
863Template rendering
863Bindings: plays
andplaybooks
864Roles 866
Recommendations for
structuring
theconfiguration
base 868 Ansibleaccessoptions
869IntroductiontoSalt 871
Minion
setup
873Variable value
binding
forminions 874Minion
matching
876Saltstates 877
Salt and
Jinja
878State IDs and
dependencies
880Stateandexecutionfunctions 882 Parametersandnames 883
State
binding
tominions 886Highstates
886Salt formulas 887
Environments 888
Documentation
roadmap
892 Ansible and Saltcompared
893Deployment
flexibility
andscalability
893Built-in modules and
extensibility
894Security
894 Miscellaneous 895 Bestpractices
895 Recommendedreading
899Chapter
24
Virtualization
900 Virtual vernacular 901Hypervisors
901 Fullvirtualization 901 Paravirtualization 902 Hardware-assisted virtualization 902 Paravirtualized drivers 902Modern virtualization 903
Type
1 vs.type2hypervisors
903Live
migration
904Virtual machine
images
904Containerization 904
VirtualizationwithLinux 905
Xen 906
Xenguest installation 907
KVM 908 KVMguestinstallation 909
FreeBSDbhyve
910 VMware 910 VirtualBox 911 Packer 911Vagrant
913 Recommendedreading
914Chapter
25Containers
915Background
andcoreconcepts 916Kernel support 917
Images
917Networking
918Docker: theopensourcecontainer
engine
919Basicarchitecture 919
Installation 921
Client setup 921
Thecontainer
experience
922Volumes 926 Data volumecontainers 927
Dockernetworks 927
Namespaces
and thebridge
network 928 Networkoverlays
930Storage
drivers 930 dockerdoption
editing
930Image
building
932Choosing
abaseimage
933Building
fromaDockerfile 933Composing
aderived Dockerfile 934Registries
936TableofContents xxxiii
Containersin
practice
937Logging
938Security
advice 939Restrictaccesstothe daemon 939
UseTLS 940
Runprocessesas
unprivileged
users 940Usea
read-only
rootfilesystem
941Limit
capabilities
941Secure
images
941Debugging
andtroubleshooting
942Container
clustering
andmanagement 942A
synopsis
ofcontainermanagement software 944Kubernetes 944 Mesos and Marathon 946
DockerSwarm 947 AWS EC2 Container Service 947
Recommended
reading
948Chapter
26Continuous
Integration
andDelivery
949 CI/CDessentials 951Principles
andpractices
951Use revision control 952 Buildonce,
deploy
often 952Automate end-to-end 952 Build every
integration
commit 952 Shareresponsibility
953 Buildfast,fixfast 953 Audit andverify
953Environments 953
Feature
flags
955Pipelines
955The buildprocess 956
Testing
957Deployment
959Zero-downtime
deployment
techniques
960Jenkins:
the opensourceautomationserver 961 BasicJenkins
concepts 962 Distributed builds 963CI/CD in
practice
964UlsahGo,
atrivial webapplication
966Unit
testing
UlsahGo 966Taking
first steps withtheJenkins
Pipeline
968Building
aDigitalOcean
image
970Provisioning
asingle
system fortesting
972Testing
thedroplet
975Deploying
UlsahGotoapair
ofdroplets
andaloadbalancer 976Concluding
the demonstrationpipeline
977ContainersandCI/CD 978
Containersas abuildenvironment 979
Container
images
asbuildartifacts 979Recommended
reading
980Chapter
27Security
981Elementsof
security
983How
security
iscompromised
983 Socialengineering
• 983 Softwarevulnerabilities 984Distributeddenial-of-service attacks
(DDoS)
985Insiderabuse 986
Network,
system,orapplication configuration
errors 986Basic
security
measures 987Software
updates
987Unnecessary
services 988 Remoteeventlogging
989Backups
989Virusesandworms 989
Rootkits 990
Packet
filtering
991 Passwords and multifactor authentication 991Vigilance
991Application
penetration testing
992Passwords anduseraccounts 992 Password
changes
993 Password vaults andpassword
escrow 993Password
aging
995Group
logins
and sharedlogins
996User shells 996
Table of Contents *xxv
Security
powertools 996Nmap:
network portscanner 996Nessus:
next-generation
networkscanner 998Metasploit:
penetration testing
software 999Lynis:
on-boxsecurity
auditing
999John
theRipper:
finder ofinsecurepasswords
1000Bro:the
programmable
networkintrusiondetectionsystem 1000Snort: the
popular
networkintrusiondetectionsystem 1001 OSSEC: host-basedintrusiondetection 1002 OSSEC basicconcepts 1002OSSEC installation 1003
OSSEC
configuration
1004Fail2Ban: brute-force attack responsesystem 1004
Cryptography
primer
1005Symmetric key
cryptography
1005 Publickey cryptography
1006 Publickey
infrastructure 1007Transport Layer Security
1009Cryptographic
hashfunctions 1009Randomnumber
generation
1011Cryptographic
softwareselection 1012The
openssl
command 1012Preparing
keys
and certificates 1013Debugging
TLSservers 1014PGP:
Pretty
GoodPrivacy
1014Kerberos:aunified
approach
tonetworksecurity
1015SSH,the Secure SHell 1016
OpenSSH
essentials 1016The ssh client 1018
Public
key
authentication 1019The
ssh-agent
1020Host aliasesin
~/.ssh/config
1022Connection
multiplexing
1023Port
forwarding
1023sshd: the
OpenSSH
server 1024Host
key
verification with SSHFP 1026File transfers 1027
Alternativesforsecure
logins
1027Firewalls 1027
Packet-filtering
firewalls 1028Filtering
ofservices 1028Stateful
inspection
firewalls 1029 Firewalls: safe? 1029Virtual
private
networks(VPNs)
1030IPsec tunnels 1030
All I needisaVPN,
right?
1031Certifications and standards 1031
Certifications 1031
Security
standards 1032ISO 27001:2013 1032
PCI DSS 1033
NIST800 series 1033
The Common Criteria 1034 OWASP: the
Open
WebApplication Security Project
1034 CIS: the Center for InternetSecurity
1034 Sources ofsecurity
information 1034SecurityFocus.com,
theBugTraq mailing
list,and the OSSmailing
list.. 1035Schneieron
Security
1035The Verizon Data Breach
Investigations
Report
1035 The SANS Institute 1035Distribution-specific security
resources 1036Other
mailing
lists and web sites 1036 When your site has beenattacked 1037 Recommendedreading
1038Chapter
28Monitoring
1040An overview of
monitoring
1041 Instrumentation 1042Datatypes
1042Intake and
processing
1043Notifications 1043
Dashboards and UIs 1044 The
monitoring
culture 1044The
monitoring
platforms
1045Open
sourcereal-timeplatforms
1046Nagios
andIcinga
1046Sensu 1047
Open
sourcetime-seriesplatforms
1047Graphite
1047Prometheus 1048
InfluxDB 1049
Munin 1049
Open
sourcecharting platforms
1049Commercial
monitoring
platforms
1050TableofContents xxxvii
Datacollection 1051 StatsD:
generic
data submissionprotocol
1052Data
harvesting
from command output 1054Network
monitoring
1055Systems
monitoring
1056Commands forsystems
monitoring
1057collectd:
generalized
system
dataharvester 1057sysdig
and dtrace:execution tracers 1058Application monitoring
1059Log monitoring
1059Supervisor
+Munin: asimple
optionfor limited domains 1060 Commercialapplication
monitoring
tools 1060Security monitoring
1061System integrity
verification 1061 Intrusion detectionmonitoring
1062 SNMP:theSimple
NetworkManagement
Protocol 1063 SNMPorganization
1064SNMP
protocol
operations
1065Net-SNMP: toolsforservers 1065
Tips
andtricks formonitoring
1068 Recommendedreading
1069Chapter
29Performance
Analysis
1070
Performance
tuning
philosophy
1071Ways
toimprove
performance
1073 Factorsthat affectperformance
1074StolenCPU
cycles
1075Analysis
ofperformance problems
1076System performance checkup
1077Taking
stock of yourequipment
1077Gathering
performance
data 1079Analyzing
CPU usage 1079Understanding
how the systemmanages memory 1081Analyzing
memory usage 1082Analyzing
diskI/O 1084fio:
testing storage
subsystem performance
1085sar:
collecting
andreporting
statisticsovertime 1086Choosing
aLinuxI/Oscheduler 1086perf:
profiling
Linuxsystemsin detail 1087Help! My
serverjust
gotreally
slow! 1088 Recommendedreading
1090Chapter
30 Data CenterBasics
1091
Racks 1092
Power 1092
Rackpower requirements 1093
kVAvs.kW 1094
Energy efficiency
1095Metering
1095Cost 1096
Remote control 1096
Cooling
andenvironment 1096Cooling
loadestimation 1097Roof, walls,and windows 1097
Electronicgear 1097
Light
fixtures 1098Operators
1098Total heat load 1098
Hot aisles and cold aisles 1098
Humidity
1100Environmental
monitoring
1100Datacenter
reliability
tiers 1101Datacentersecurity 1102
Location 1102 Perimeter 1102
Facility
access 1102 Rackaccess 1103 Tools 1103 Recommendedreading
1104Chapter
31Methodology, Policy,
and
Politics 1105The
grand
unifiedtheory:
DevOps
1106DevOps
isCLAMS 1107 Culture 1107 Lean 1108 Automation 1109 Measurement 1110Sharing
1110System
administration inaDevOps
world 1110Ticketing
and taskmanagement systems 1111 Common functionsofticketing
systems 1112Ticket
ownership
1112Useracceptance of
ticketing
systems 1113Sample
ticketing
systems 1114Table ofContents xxxix
Localdocumentationmaintenance 1115
Infrastructureascode 1116 Documentationstandards 1116 Environment
separation
1118 Disastermanagement 1119 Riskassessment 1119Recovery planning
1120Staffing
foradisaster 1121Security
incidents 1122 ITpolicies
andprocedures
1122The differencebetween
policies
andprocedures
1123Policy
best practices 1124Procedures 1124
Servicelevel agreements 1125
Scope
anddescriptions
of services 1125Queue
prioritization policies
1126Conformancemeasurements 1127
Compliance: regulations
and standards 1127Legal
issues 1131Privacy
1131Policy
enforcement 1132Control=
liability
1132Software licenses 1133
Organizations,
conferences,and otherresources 1133 Recommendedreading
1135Index
1136A Brief