100% found this document useful (1 vote)
22 views

How Linux Works What Every Superuser Should Know 3rd Edition Brian Ward - The full ebook set is available with all chapters for download

The document promotes the ebook 'How Linux Works: What Every Superuser Should Know' by Brian Ward, available for download at textbookfull.com. It includes links to various editions and related titles, along with reviews highlighting its value for understanding Linux architecture. The book covers essential topics for superusers, making it a recommended resource for those interested in Linux.

Uploaded by

bebkosusca9q
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 (1 vote)
22 views

How Linux Works What Every Superuser Should Know 3rd Edition Brian Ward - The full ebook set is available with all chapters for download

The document promotes the ebook 'How Linux Works: What Every Superuser Should Know' by Brian Ward, available for download at textbookfull.com. It includes links to various editions and related titles, along with reviews highlighting its value for understanding Linux architecture. The book covers essential topics for superusers, making it a recommended resource for those interested in Linux.

Uploaded by

bebkosusca9q
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/ 66

Explore the full ebook collection and download it now at textbookfull.

com

How Linux Works What Every Superuser Should Know


3rd Edition Brian Ward

https://textbookfull.com/product/how-linux-works-what-every-
superuser-should-know-3rd-edition-brian-ward-2/

OR CLICK HERE

DOWLOAD EBOOK

Browse and Get More Ebook Downloads Instantly at https://textbookfull.com


Click here to visit textbookfull.com and download textbook now
Your digital treasures (PDF, ePub, MOBI) await
Download instantly and pick your perfect format...

Read anywhere, anytime, on any device!

How Linux Works What Every Superuser Should Know 3rd


Edition Brian Ward

https://textbookfull.com/product/how-linux-works-what-every-superuser-
should-know-3rd-edition-brian-ward-2/

textbookfull.com

How Linux Works What Every Superuser Should Know Brian


Ward

https://textbookfull.com/product/how-linux-works-what-every-superuser-
should-know-brian-ward/

textbookfull.com

How Linux Works 3rd Edition Brian Ward

https://textbookfull.com/product/how-linux-works-3rd-edition-brian-
ward/

textbookfull.com

What Every Science Student Should Know Justin Bauer

https://textbookfull.com/product/what-every-science-student-should-
know-justin-bauer/

textbookfull.com
What Every Engineer Should Know About Excel Jack P. Holman

https://textbookfull.com/product/what-every-engineer-should-know-
about-excel-jack-p-holman/

textbookfull.com

Vinod Pottayil What Every Indian Should Know Before


Investing First Edition Vinod Pottayil

https://textbookfull.com/product/vinod-pottayil-what-every-indian-
should-know-before-investing-first-edition-vinod-pottayil/

textbookfull.com

What Every Engineer Should Know About Modeling and


Simulation 1st Edition Raymond J. Madachy

https://textbookfull.com/product/what-every-engineer-should-know-
about-modeling-and-simulation-1st-edition-raymond-j-madachy/

textbookfull.com

What Every Engineer Should Know about Reliability and Risk


Analysis First Edition Mohammad Modarres

https://textbookfull.com/product/what-every-engineer-should-know-
about-reliability-and-risk-analysis-first-edition-mohammad-modarres/

textbookfull.com

What Every Woman Should Know about Cervical Cancer Revised


and Updated 2nd Edition Nenad Markovic

https://textbookfull.com/product/what-every-woman-should-know-about-
cervical-cancer-revised-and-updated-2nd-edition-nenad-markovic/

textbookfull.com
3RD EDITION

HOW
LINUX
WORKS
W H A T E V E R Y S U P E R U S E R S H O U L D K N O W

BRIAN WARD
REVIEWS FOR
HOW LINUX WORKS

“If you are interested in Linux, How Linux Works: What Every Superuser Should
Know is a must-read title.”
—LinuxInsider

“Lots to offer on almost every aspect of the Linux architecture.”


—Everyday Linux User

“You’ll get an essential understanding of what’s going on under the hood with-
out getting bogged down in minutiae—making this a very refreshing (and
wholly recommended) addition to the Linux literature.”
—Phil Bull, co-author of Ubuntu
M ade Easy and member of the
Ubuntu documentation team

“Dives straight into the transparent depths of Linux-based operating systems


and shows us how all the pieces fit together.”
—DistroWatch

“Earns its place on the shelf as an essential reference.”


—The M agPi magazine
HOW LINUX
WORKS
3rd Edition
What Every Superuser
Should Know

b y Br i a n Wa r d

San Francisco
HOW LINUX WORKS, 3RD EDITION. Copyright © 2021 by Brian Ward.

All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means,
electronic or mechanical, including photocopying, recording, or by any information storage or retrieval
system, without the prior written permission of the copyright owner and the publisher.

ISBN-13: 978-1-7185-0040-2 (print)


ISBN-13: 978-1-7185-0041-9 (ebook)

Publisher: William Pollock


Executive Editor: Barbara Yien
Production Editor: Rachel Monaghan
Developmental Editors: Larry Wake and Jill Franklin
Cover and Interior Design: Octopod Studios
Technical Reviewers: Jordi Gutiérrez Hermoso and Petros Koutoupis
Copyeditor: Rachel Monaghan
Compositor: Cody Gates, Happenstance Type-O-Rama
Proofreader: James M. Fraleigh

For information on book distributors or translations, please contact No Starch Press, Inc. directly:
No Starch Press, Inc.
245 8th Street, San Francisco, CA 94103
phone: 1-415-863-9900; [email protected]
www.nostarch.com

The Library of Congress has catalogued the first edition as follows:

Ward, Brian.
How Linux works : what every superuser should know / Brian Ward.
p. cm.
Includes index.
ISBN 1-59327-035-6
1. Linux. 2. Operating systems (Computers). I. Title.
QA76.76.O63 W3654 2004
005.4’32--dc22
2004002692

No Starch Press and the No Starch Press logo are registered trademarks of No Starch Press, Inc. Other
product and company names mentioned herein may be the trademarks of their respective owners. Rather
than use a trademark symbol with every occurrence of a trademarked name, we are using the names only
in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of
the trademark.

The information in this book is distributed on an “As Is” basis, without warranty. While every precaution
has been taken in the preparation of this work, neither the author nor No Starch Press, Inc. shall have any
liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly
or indirectly by the information contained in it.
About the Author
Brian Ward has been working with Linux since 1993. He is also the
author of The Linux Kernel HOWTO, The Book of VMware (No Starch
Press), and The Linux Problem Solver (No Starch Press).

About the Technical Reviewers


Jordi Gutiérrez Hermoso is a GNU/Linux user and developer with
almost two decades of experience, with occasional contributions in vari-
ous circles of the free software communities, such as GNU Octave and
Mercurial. His professional work has allowed him to collaborate with
and learn about diverse topics such as digital cryptographic signatures,
medical imaging, and most recently greenhouse gas accounting and
ecological map data, all built entirely with Linux and other free soft-
ware. When he is not near a computer he enjoys swimming, mathematics,
and knitting.

Petros Koutoupis is currently a senior performance software engineer


at HPE (formerly Cray Inc.) for its Lustre High Performance File System
division. He is also the creator and maintainer of the RapidDisk Project
(www.rapiddisk.org). Petros has worked in the data storage industry
for well over a decade and has helped pioneer the many technologies
unleashed in the wild today.
BRIEF CONTENTS

Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxi

Chapter1: The Big Picture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

Chapter 2: Basic Commands and Directory Hierarchy . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

Chapter 3: Devices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47

Chapter 4: Disks and Filesystems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69

Chapter 5: How the Linux Kernel Boots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117

Chapter 6: How User Space Starts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137

Chapter 7: System Configuration: Logging, System Time, Batch Jobs, and Users . . . . . . . . . 167

Chapter 8: A Closer Look at Processes and Resource Utilization . . . . . . . . . . . . . . . . . . . . 199

Chapter 9: Understanding Your Network and Its Configuration . . . . . . . . . . . . . . . . . . . . . 223

Chapter 10: Network Applications and Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269

Chapter 11: Introduction to Shell Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291

Chapter 12: Network File Transfer and Sharing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315

Chapter 13: User Environments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 335

Chapter 14: A Brief Survey of the Linux Desktop and Printing . . . . . . . . . . . . . . . . . . . . . . 347

Chapter 15: Development Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 363

Chapter 16: Introduction to Compiling Software from C Source Code . . . . . . . . . . . . . . . . 385

Chapter 17: Virtualization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 401

Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 419

Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 423
CO N T E N T S I N D E TA I L

PREFACE XXI
Who Should Read This Book? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxi
Prerequisites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxii
How to Read This Book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxii
A Hands-on Approach . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxii
How This Book Is Organized . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxiii
What’s New in the Third Edition? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxiii
A Note on Terminology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxiv

1
THE BIG PICTURE 1
1.1 Levels and Layers of Abstraction in a Linux System . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.2 Hardware: Understanding Main Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.3 The Kernel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.3.1 Process Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.3.2 Memory Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.3.3 Device Drivers and Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.3.4 System Calls and Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.4 User Space . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.5 Users . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
1.6 Looking Forward . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

2
BASIC COMMANDS AND DIRECTORY HIERARCHY 11
2.1 The Bourne Shell: /bin/sh . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2.2 Using the Shell . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2.2.1 The Shell Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.2.2 cat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.2.3 Standard Input and Standard Output . . . . . . . . . . . . . . . . . . . . . . . . . 14
2.3 Basic Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
2.3.1 ls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
2.3.2 cp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
2.3.3 mv . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
2.3.4 touch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
2.3.5 rm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
2.3.6 echo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
2.4 Navigating Directories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
2.4.1 cd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
2.4.2 mkdir . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
2.4.3 rmdir . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
2.4.4 Shell Globbing (“Wildcards”) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
2.5 Intermediate Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
2.5.1 grep . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
2.5.2 less . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
2.5.3 pwd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
2.5.4 diff . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
2.5.5 file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
2.5.6 find and locate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
2.5.7 head and tail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
2.5.8 sort . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
2.6 Changing Your Password and Shell . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
2.7 Dot Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
2.8 Environment and Shell Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
2.9 The Command Path . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
2.10 Special Characters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
2.11 Command-Line Editing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
2.12 Text Editors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
2.13 Getting Online Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
2.14 Shell Input and Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
2.14.1 Standard Error . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
2.14.2 Standard Input Redirection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
2.15 Understanding Error Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
2.15.1 Anatomy of a Unix Error Message . . . . . . . . . . . . . . . . . . . . . . . . . 30
2.15.2 Common Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
2.16 Listing and Manipulating Processes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
2.16.1 Command Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
2.16.2 Process Termination . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
2.16.3 Job Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
2.16.4 Background Processes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
2.17 File Modes and Permissions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
2.17.1 Modifying Permissions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
2.17.2 Working with Symbolic Links . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
2.18 Archiving and Compressing Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
2.18.1 gzip . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
2.18.2 tar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
2.18.3 Compressed Archives (.tar.gz) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
2.18.4 zcat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
2.18.5 Other Compression Utilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
2.19 Linux Directory Hierarchy Essentials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
2.19.1 Other Root Subdirectories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
2.19.2 The /usr Directory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
2.19.3 Kernel Location . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
2.20 Running Commands as the Superuser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
2.20.1 sudo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
2.20.2 /etc/sudoers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
2.20.3 sudo Logs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
2.21 Looking Forward . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46

3
DEVICES 47
3.1 Device Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
3.2 The sysfs Device Path . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49

x Contents in Detail
3.3 dd and Devices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
3.4 Device Name Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
3.4.1 Hard Disks: /dev/sd* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
3.4.2 Virtual Disks: /dev/xvd*, /dev/vd* . . . . . . . . . . . . . . . . . . . . . . . . . 53
3.4.3 Non-Volatile Memory Devices: /dev/nvme* . . . . . . . . . . . ..... . . . 53
3.4.4 Device Mapper: /dev/dm-*, /dev/mapper/* . . . . . . . . . . . . . . . . . . 53
3.4.5 CD and DVD Drives: /dev/sr* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
3.4.6 PATA Hard Disks: /dev/hd* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
3.4.7 Terminals: /dev/tty*, /dev/pts/*, and /dev/tty . . . . . . . . . . . . . . . . . 53
3.4.8 Serial Ports: /dev/ttyS*, /dev/ttyUSB*, /dev/ttyACM* . . . . . . . . . . . 55
3.4.9 Parallel Ports: /dev/lp0 and /dev/lp1 . . . . . . . . . . . . . . . . . . . . . . . 55
3.4.10 Audio Devices: /dev/snd/*, /dev/dsp, /dev/audio, and More . . . . 55
3.4.11 Device File Creation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
3.5 udev . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
3.5.1 devtmpfs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
3.5.2 udevd Operation and Configuration . . . . . . . . . . . . . . . . . . . . . . . . . 58
3.5.3 udevadm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
3.5.4 Device Monitoring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
3.6 In-Depth: SCSI and the Linux Kernel . . . . . . . . . . . . . . . . . . . . . . . . . ..... . . . 62
3.6.1 USB Storage and SCSI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
3.6.2 SCSI and ATA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
3.6.3 Generic SCSI Devices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
3.6.4 Multiple Access Methods for a Single Device . . . . . . . . . . . . . . . . . . . 67

4
DISKS AND FILESYSTEMS 69
4.1 Partitioning Disk Devices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
4.1.1 Viewing a Partition Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
4.1.2 Modifying Partition Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
4.1.3 Creating a Partition Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
4.1.4 Navigating Disk and Partition Geometry . . . . . . . . . . . . . . . . . . . . . . 78
4.1.5 Reading from Solid-State Disks . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
4.2 Filesystems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
4.2.1 Filesystem Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
4.2.2 Creating a Filesystem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
4.2.3 Mounting a Filesystem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
4.2.4 Filesystem UUID . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
4.2.5 Disk Buffering, Caching, and Filesystems . . . . . . . . . . . . . . . . . . . . . . 86
4.2.6 Filesystem Mount Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
4.2.7 Remounting a Filesystem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
4.2.8 The /etc/fstab Filesystem Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
4.2.9 Alternatives to /etc/fstab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
4.2.10 Filesystem Capacity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
4.2.11 Checking and Repairing Filesystems . . . . . . . . . . . . . . . . . . . . . . . . 91
4.2.12 Special-Purpose Filesystems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
4.3 Swap Space . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
4.3.1 Using a Disk Partition as Swap Space . . . . . . . . . . . . . . . . . . . . . . . . 94
4.3.2 Using a File as Swap Space . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
4.3.3 Determining How Much Swap You Need . . . . . . . . . . . . . . . . . . . . . . 95
4.4 The Logical Volume Manager . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
4.4.2 Working with LVM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
4.4.3 The LVM Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107

Contents in Detail  xi
4.5 Looking Forward: Disks and User Space . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
4.6 Inside a Traditional Filesystem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
4.6.1 Inode Details and the Link Count . . . . . . . . . . . . . . . . . . . . . . . . . . 113
4.6.2 Block Allocation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
4.6.3 Working with Filesystems in User Space . . . . . . . . . . . . . . . . . . . . . 115

5
HOW THE LINUX KERNEL BOOTS 117
5.1 Startup Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118
5.2 Kernel Initialization and Boot Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
5.3 Kernel Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
5.4 Boot Loaders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
5.4.1 Boot Loader Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122
5.4.2 Boot Loader Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
5.5 GRUB Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
5.5.1 Exploring Devices and Partitions with the GRUB Command Line . . . . . 125
5.5.2 GRUB Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
5.5.3 GRUB Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
5.6 UEFI Secure Boot Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
5.7 Chainloading Other Operating Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132
5.8 Boot Loader Details . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132
5.8.1 MBR Boot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133
5.8.2 UEFI Boot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133
5.8.3 How GRUB Works . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134

6
HOW USER SPACE STARTS 137
6.1 Introduction to init . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
6.2 Identifying Your init . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
6.3 systemd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
6.3.1 Units and Unit Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140
6.3.2 Booting and Unit Dependency Graphs . . . . . . . . . . . . . . . . . . . . . . 140
6.3.3 systemd Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
6.3.4 systemd Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144
6.3.5 systemd Process Tracking and Synchronization . . . . . . . . . . . . . . . . . 147
6.3.6 systemd Dependencies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
6.3.7 systemd On-Demand and Resource-Parallelized Startup . . . . . . . . . . . 151
6.3.8 systemd Auxiliary Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
6.4 System V Runlevels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
6.5 System V init . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
6.5.1 System V init: Startup Command Sequence . . . . . . . . . . . . . . . . . . . 158
6.5.2 The System V init Link Farm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
6.5.3 run-parts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
6.5.4 System V init Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161
6.5.5 systemd System V Compatibility . . . . . . . . . . . . . . . . . . . . . . . . . . . 161
6.6 Shutting Down Your System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162
6.7 The Initial RAM Filesystem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
6.8 Emergency Booting and Single-User Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
6.9 Looking Forward . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165

xii Contents in Detail


7
SYSTEM CONFIGURATION:
LOGGING, SYSTEM TIME, BATCH JOBS, AND USERS 167
7.1 System Logging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168
7.1.1 Checking Your Log Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
7.1.2 Searching and Monitoring Logs . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
7.1.3 Logfile Rotation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172
7.1.4 Journal Maintenance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
7.1.5 A Closer Look at System Logging . . . . . . . . . . . . . . . . . . . . . . . . . . 173
7.2 The Structure of /etc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176
7.3 User Management Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
7.3.1 The /etc/passwd File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
7.3.2 Special Users . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178
7.3.3 The /etc/shadow File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179
7.3.4 Manipulating Users and Passwords . . . . . . . . . . . . . . . . . . . . . . . . . 179
7.3.5 Working with Groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180
7.4 getty and login . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
7.5 Setting the Time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
7.5.1 Kernel Time Representation and Time Zones . . . . . . . . . . . . . . . . . . . 182
7.5.2 Network Time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182
7.6 Scheduling Recurring Tasks with cron and Timer Units . . . . . . . . . . . . . . . . . . . . . 183
7.6.1 Installing Crontab Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
7.6.2 System Crontab Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185
7.6.3 Timer Units . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185
7.6.4 cron vs. Timer Units . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187
7.7 Scheduling One-Time Tasks with at . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187
7.7.1 Timer Unit Equivalents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188
7.8 Timer Units Running as Regular Users . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188
7.9 User Access Topics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
7.9.1 User IDs and User Switching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
7.9.2 Process Ownership, Effective UID, Real UID, and Saved UID . . . . . . . 189
7.9.3 User Identification, Authentication, and Authorization . . . . . . . . . . . . 191
7.9.4 Using Libraries for User Information . . . . . . . . . . . . . . . . . . . . . . . . . 192
7.10 Pluggable Authentication Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192
7.10.1 PAM Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193
7.10.2 Tips on PAM Configuration Syntax . . . . . . . . . . . . . . . . . . . . . . . . 196
7.10.3 PAM and Passwords . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197
7.11 Looking Forward . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198

8
A CLOSER LOOK AT PROCESSES AND RESOURCE UTILIZATION 199
8.1 Tracking Processes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200
8.2 Finding Open Files with lsof . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200
8.2.1 Reading the lsof Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201
8.2.2 Using lsof . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202
8.3 Tracing Program Execution and System Calls . . . . . . . . . . . . . . . . . . . . . . . . . . 202
8.3.1 strace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202
8.3.2 ltrace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204
8.4 Threads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204
8.4.1 Single-Threaded and Multithreaded Processes . . . . . . . . . . . . . . . . . 204
8.4.2 Viewing Threads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205


Contents in Detail xiii
8.5 Introduction to Resource Monitoring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206
8.5.1 Measuring CPU Time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207
8.5.2 Adjusting Process Priorities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207
8.5.3 Measuring CPU Performance with Load Averages . . . . . . . . . . . . . . . 208
8.5.4 Monitoring Memory Status . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210
8.5.5 Monitoring CPU and Memory Performance with vmstat . . . . . . . . . . . 212
8.5.6 I/O Monitoring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214
8.5.7 Per-Process Monitoring with pidstat . . . . . . . . . . . . . . . . . . . . . . . . . 216
8.6 Control Groups (cgroups) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216
8.6.1 Differentiating Between cgroup Versions . . . . . . . . . . . . . . . . . . . . . 217
8.6.2 Viewing cgroups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219
8.6.3 Manipulating and Creating cgroups . . . . . . . . . . . . . . . . . . . . . . . . 220
8.6.4 Viewing Resource Utilization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221
8.7 Further Topics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221

9
UNDERSTANDING YOUR NETWORK AND ITS CONFIGURATION 223
9.1 Network Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224
9.2 Packets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224
9.3 Network Layers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225
9.4 The Internet Layer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226
9.4.1 Viewing IP Addresses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228
9.4.2 Subnets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228
9.4.3 Common Subnet Masks and CIDR Notation . . . . . . . . . . . . . . . . . . . 229
9.5 Routes and the Kernel Routing Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230
9.6 The Default Gateway . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231
9.7 IPv6 Addresses and Networks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231
9.7.1 Viewing IPv6 Configuration on Your System . . . . . . . . . . . . . . . . . . . 232
9.7.2 Configuring Dual-Stack Networks . . . . . . . . . . . . . . . . . . . . . . . . . . 233
9.8 Basic ICMP and DNS Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234
9.8.1 ping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234
9.8.2 DNS and host . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235
9.9 The Physical Layer and Ethernet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235
9.10 Understanding Kernel Network Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . 236
9.11 Introduction to Network Interface Configuration . . . . . . . . . . . . . . . . . . . . . . . 237
9.11.1 Manually Configuring Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . 237
9.11.2 Manually Adding and Deleting Routes . . . . . . . . . . . . . . . . . . . . . . 238
9.12 Boot-Activated Network Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239
9.13 Problems with Manual and Boot-Activated Network Configuration . . . . . . . . . . 239
9.14 Network Configuration Managers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240
9.14.1 NetworkManager Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241
9.14.2 NetworkManager Interaction . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241
9.14.3 NetworkManager Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . 242
9.15 Resolving Hostnames . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243
9.15.1 /etc/hosts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244
9.15.2 resolv.conf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245
9.15.3 Caching and Zero-Configuration DNS . . . . . . . . . . . . . . . . . . . . . . 245
9.15.4 /etc/nsswitch.conf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246
9.16 Localhost . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247
9.17 The Transport Layer: TCP, UDP, and Services . . . . . . . . . . . . . . . . . . . . . . . . . 247
9.17.1 TCP Ports and Connections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 248
9.17.2 UDP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250

xiv Contents in Detail


9.18 Revisiting a Simple Local Network . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252
9.19 Understanding DHCP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252
9.19.1 Linux DHCP Clients . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253
9.19.2 Linux DHCP Servers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253
9.20 Automatic IPv6 Network Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253
9.21 Configuring Linux as a Router . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254
9.22 Private Networks (IPv4) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256
9.23 Network Address Translation (IP Masquerading) . . . . . . . . . . . . . . . . . . . . . . . 256
9.24 Routers and Linux . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258
9.25 Firewalls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259
9.25.1 Linux Firewall Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259
9.25.2 Setting Firewall Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261
9.25.3 Firewall Strategies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262
9.26 Ethernet, IP, ARP, and NDP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 264
9.27 Wireless Ethernet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266
9.27.1 iw . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267
9.27.2 Wireless Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268
9.28 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268

10
NETWORK APPLICATIONS AND SERVICES 269
10.1 The Basics of Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 270
10.2 A Closer Look . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271
10.3 Network Servers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272
10.3.1 Secure Shell . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273
10.3.2 The sshd Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274
10.3.3 fail2ban . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276
10.3.4 The SSH Client . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 277
10.4 Pre-systemd Network Connection Servers: inetd/xinetd . . . . . . . . . . . . . . . . . . . . . 278
10.5 Diagnostic Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279
10.5.1 lsof . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280
10.5.2 tcpdump . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281
10.5.3 netcat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283
10.5.4 Port Scanning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284
10.6 Remote Procedure Calls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284
10.7 Network Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285
10.7.1 Typical Vulnerabilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286
10.7.2 Security Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287
10.8 Looking Forward . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287
10.9 Network Sockets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288
10.10 Unix Domain Sockets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289

11
INTRODUCTION TO SHELL SCRIPTS 291
11.1 Shell Script Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291
11.1.1 Limitations of Shell Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292
11.2 Quoting and Literals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293
11.2.1 Literals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293
11.2.2 Single Quotes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294
11.2.3 Double Quotes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295
11.2.4 Literal Single Quotes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295

Contents in Detail xv
11.3 Special Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296
11.3.1 Individual Arguments: $1, $2, and So On . . . . . . . . . . . . . . . . . . . 296
11.3.2 Number of Arguments: $# . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297
11.3.3 All Arguments: $@ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297
11.3.4 Script Name: $0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297
11.3.5 Process ID: $$ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 298
11.3.6 Exit Code: $? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 298
11.4 Exit Codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 298
11.5 Conditionals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299
11.5.1 A Workaround for Empty Parameter Lists . . . . . . . . . . . . . . . . . . . . 299
11.5.2 Other Commands for Tests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 300
11.5.3 elif . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 300
11.5.4 Logical Constructs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 300
11.5.5 Testing Conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 301
11.5.6 case . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 304
11.6 Loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 305
11.6.1 for Loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 305
11.6.2 while Loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 305
11.7 Command Substitution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 306
11.8 Temporary File Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 307
11.9 Here Documents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 308
11.10 Important Shell Script Utilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 308
11.10.1 basename . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 308
11.10.2 awk . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309
11.10.3 sed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309
11.10.4 xargs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 310
11.10.5 expr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 311
11.10.6 exec . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 311
11.11 Subshells . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 311
11.12 Including Other Files in Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 312
11.13 Reading User Input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 312
11.14 When (Not) to Use Shell Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 312

12
NETWORK FILE TRANSFER AND SHARING 315
12.1 Quick Copy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 316
12.2 rsync . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317
12.2.1 Getting Started with rsync . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317
12.2.2 Making Exact Copies of a Directory Structure . . . . . . . . . . . . . . . . . 318
12.2.3 Using the Trailing Slash . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 319
12.2.4 Excluding Files and Directories . . . . . . . . . . . . . . . . . . . . . . . . . . . 320
12.2.5 Checking Transfers, Adding Safeguards,
and Using Verbose Mode . . . . . . . . . . . . . . . . . . . . . . . ...... 321
12.2.6 Compressing Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 321
12.2.7 Limiting Bandwidth . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322
12.2.8 Transferring Files to Your Computer . . . . . . . . . . . . . . . . . . . . . . . . 322
12.2.9 Further rsync Topics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322
12.3 Introduction to File Sharing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 323
12.3.1 File Sharing Usage and Performance . . . . . . . . . . . . . . . . ...... 323
12.3.2 File Sharing Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 323

xvi Contents in Detail


12.4 Sharing Files with Samba . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 324
12.4.1 Server Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 324
12.4.2 Server Access Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325
12.4.3 Passwords . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 326
12.4.4 Manual Server Startup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327
12.4.5 Diagnostics and Logfiles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 328
12.4.6 File Share Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 328
12.4.7 Home Directories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 328
12.4.8 Printer Sharing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 329
12.4.9 The Samba Client . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 329
12.5 SSHFS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 331
12.6 NFS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 332
12.7 Cloud Storage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 333
12.8 The State of Network File Sharing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 333

13
USER ENVIRONMENTS 335
13.1 Guidelines for Creating Startup Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 336
13.2 When to Alter Startup Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 336
13.3 Shell Startup File Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337
13.3.1 The Command Path . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337
13.3.2 The Manual Page Path . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 338
13.3.3 The Prompt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 338
13.3.4 Aliases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 339
13.3.5 The Permissions Mask . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 339
13.4 Startup File Order and Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 340
13.4.1 The bash Shell . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 340
13.4.2 The tcsh Shell . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 342
13.5 Default User Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 343
13.5.1 Shell Defaults . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 343
13.5.2 Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 344
13.5.3 Pager . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 344
13.6 Startup File Pitfalls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 344
13.7 Further Startup Topics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 345

14
A BRIEF SURVEY OF THE LINUX DESKTOP AND PRINTING 347
14.1 Desktop Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 348
14.1.1 Framebuffers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 348
14.1.2 The X Window System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 348
14.1.3 Wayland . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349
14.1.4 Window Managers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349
14.1.5 Toolkits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 350
14.1.6 Desktop Environments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 350
14.1.7 Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 350
14.2 Are You Running Wayland or X? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 351
14.3 A Closer Look at Wayland . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 351
14.3.1 The Compositing Window Manager . . . . . . . . . . . . . . . . . . . . . . . 351
14.3.2 libinput . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 352
14.3.3 X Compatibility in Wayland . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 353


Contents in Detail xvii
14.4 A Closer Look at the X Window System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 354
14.4.1 Display Managers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355
14.4.2 Network Transparency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355
14.4.3 Ways of Exploring X Clients . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355
14.4.4 X Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 356
14.4.5 X Input and Preference Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . 357
14.5 D-Bus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 359
14.5.1 System and Session Instances . . . . . . . . . . . . . . . . . . . . . . . . . . . . 360
14.5.2 D-Bus Message Monitoring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 360
14.6 Printing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 360
14.6.1 CUPS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 361
14.6.2 Format Conversion and Print Filters . . . . . . . . . . . . . . . . . . . . . . . . 361
14.7 Other Desktop Topics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 362

15
DEVELOPMENT TOOLS 363
15.1 The C Compiler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 364
15.1.1 Compiling Multiple Source Files . . . . . . . . . . . . . . . . . . . . . . . . . . 365
15.1.2 Linking with Libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 366
15.1.3 Working with Shared Libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . 367
15.1.4 Working with Header (Include) Files and Directories . . . . . . . . . . . . 371
15.2 make . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 373
15.2.1 A Sample Makefile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 374
15.2.2 Built-in Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 374
15.2.3 Final Program Build . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 375
15.2.4 Dependency Updates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 375
15.2.5 Command-Line Arguments and Options . . . . . . . . . . . . . . . . . . . . . 376
15.2.6 Standard Macros and Variables . . . . . . . . . . . . . . . . . . . . . . . . . . 377
15.2.7 Conventional Targets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 378
15.2.8 Makefile Organization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 378
15.3 Lex and Yacc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 379
15.4 Scripting Languages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 380
15.4.1 Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 381
15.4.2 Perl . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 381
15.4.3 Other Scripting Languages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 381
15.5 Java . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 382
15.6 Looking Forward: Compiling Packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 383

16
INTRODUCTION TO COMPILING SOFTWARE
FROM C SOURCE CODE 385
16.1 Software Build Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 386
16.2 Unpacking C Source Packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 387
16.3 GNU Autoconf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 388
16.3.1 An Autoconf Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 389
16.3.2 Installation Using a Packaging Tool . . . . . . . . . . . . . . . . . . . . . . . . 390
16.3.3 configure Script Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 390
16.3.4 Environment Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 391
16.3.5 Autoconf Targets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 392
16.3.6 Autoconf Logfiles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 392
16.3.7 pkg-config . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 393

xviii Contents in Detail


16.4 Installation Practice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 394
16.4.1 Where to Install . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 395
16.5 Applying a Patch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 395
16.6 Troubleshooting Compiles and Installations . . . . . . . . . . . . . . . . . . . . . . . . . . 396
16.6.1 Specific Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 397
16.7 Looking Forward . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 399

17
VIRTUALIZATION 401
17.1 Virtual Machines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 402
17.1.1 Hypervisors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 402
17.1.2 Hardware in a Virtual Machine . . . . . . . . . . . . . . . . . . . . . . . . . . 403
17.1.3 Common Uses of Virtual Machines . . . . . . . . . . . . . . . . . . . . . . . . 404
17.1.4 Drawbacks of Virtual Machines . . . . . . . . . . . . . . . . . . . . . . . . . . 404
17.2 Containers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 405
17.2.1 Docker, Podman, and Privileges . . . . . . . . . . . . . . . . . . . . . . . . . . 406
17.2.2 A Docker Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 407
17.2.3 LXC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 414
17.2.4 Kubernetes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 415
17.2.5 Pitfalls of Containers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 415
17.3 Runtime-Based Virtualization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 417

BIBLIOGRAPHY 419

INDEX 423


Contents in Detail xix
ACKNOW LEDGMENT S

Contributions to this book come from not just those who were involved in
the development process, but also those without whom I wouldn’t know
anything about Linux. These include James Duncan, Douglas N. Arnold,
Bill Fenner, Ken Hornstein, Scott Dickson, Dan Ehrlich, Felix Lee, and
Gregory P. Smith. Previous editions included help from Karol Jurado,
Laurel Chun, Serena Yang, Alison Law, Riley Hoffman, Scott Schwartz,
Dan Sully, Dominique Poulain, Donald Karon, and Gina Steele.
This third edition benefits from the excellent work of Barbara Yien,
Rachel Monaghan, Jill Franklin, Larry Wake, Jordi Gutiérrez Hermoso,
and Petros Koutoupis. As the publisher of No Starch Press, Bill Pollock
has been instrumental in this book since the first edition. And once more,
Hsinju Hsieh has put up with me for another revision.
PR E FAC E

Your system shouldn’t be a mystery. You should be able to make your soft-
ware do what you want it to do without “magic” incantations or rituals. The
key to attaining this power lies in understanding the fundamentals of what
the software does and how it works, and that’s what this book is all about.
You should never have to fight with a computer.
Linux is a great platform for learning because it doesn’t try to hide
anything from you. In particular, you can find most system configuration
details in easy-to-read plaintext files. The only tricky part is figuring out
which parts are responsible for what and how they all fit together.

Who Should Read This Book?


Your interest in learning how Linux works may have come from any number
of sources. In the professional realm, operations and DevOps folks need to
know nearly everything that you’ll find in this book. Linux software archi-
tects and developers should also know this material in order to make the
best use of the operating system. Researchers and students, often running
their own Linux systems, will also find that this book provides useful expla-
nations for why things are set up the way they are.
Then there are the tinkerers—people who just love to play around with
their computers for fun, profit, or both. Want to know why certain things
work while others don’t? Want to know what happens if you move some-
thing around? You’re probably a tinkerer.
Prerequisites
Although Linux is beloved by programmers, you don’t need to be a pro-
grammer to read this book; you need only basic computer-user knowledge.
That is, you should be able to bumble around a GUI (especially the installer
and settings interface for a Linux distribution) and know what files and
directories (folders) are. You should also be prepared to check additional
documentation on your system and on the web. The most important thing
you need is to be ready and willing to play around with your computer.

How to Read This Book


Building the requisite knowledge is a challenge in tackling any technical
subject. Explaining how software systems work can get really complicated.
Too much detail can bog down readers and make important concepts dif-
ficult to grasp (the human brain just can’t process so many new ideas at
once), but too little detail can leave readers in the dark and unprepared for
later material.
I’ve designed most chapters to tackle the most important material first:
the basic information that you’ll need in order to progress. In places, I’ve
simplified things in order to keep focus. As a chapter progresses, you’ll see
much more detail, especially in the last few sections. Do you need to know
those bits right away? In most cases, no; I note this where applicable. If your
eyes start to glaze over when you’re faced with a lot of extra details about
concepts you just learned, don’t hesitate to skip ahead to the next chapter
or take a break. The nitty-gritty will still be there waiting for you.

A Hands-on Approach
However you choose to proceed through this book, you should have a Linux
machine in front of you, preferably one that you’re confident abusing with
experiments. You might prefer to play around with a virtual installation—I
used VirtualBox to test much of the material in this book. You also should
have superuser (root) access, but try to use a regular user account most of
the time. You’ll mostly work at the command line, in a terminal window or
a remote session. If you haven’t worked much in that environment, no prob-
lem; Chapter 2 will bring you up to speed.
Commands in this book typically look like this:

$ ls /
[some output]

Enter the text in bold; the nonbolded text that follows is what the
machine spits back. The $ is the prompt for a regular user account. If you
see a # as a prompt, you need to be superuser. (More on that in Chapter 2.)

xxii Preface
How This Book Is Organized
I’ve grouped the book’s chapters into three basic parts. The first is intro-
ductory, giving a bird’s-eye view of the system and then offering hands-on
experience with some tools you’ll need for as long as you run Linux. Next,
you’ll explore each part of the system in more detail, from device manage-
ment to network configuration, following the general order in which the
system starts. Finally, you’ll get a tour of some pieces of a running system,
learn some essential skills, and get some insight into the tools that program-
mers use.
With the exception of Chapter 2, most of the early chapters heavily
involve the Linux kernel, but you’ll work your way into user space as the
book progresses. (If you don’t know what I’m talking about here, don’t
worry; I’ll explain in Chapter 1.)
The material is meant to be as distribution-agnostic as possible. Having
said this, it can be tedious to cover all variations in systems software, so I’ve
tried to cover the two major distribution families: Debian (including Ubuntu)
and RHEL/Fedora/CentOS. I’ve also focused on desktop and server installa-
tions. A significant amount of material carries over into embedded systems,
such as Android and OpenWRT, but it’s up to you to discover the differences
on those platforms.

What’s New in the Third Edition?


The second edition was published during a time of transition for Linux
systems. Several traditional components were in the process of being
replaced, which made handling some subjects tricky, because readers could
encounter a wide variety of configurations. Now, however, those new pieces
(systemd in particular) have near-universal adoption, so I’ve been able to
streamline a fair amount of the discussion.
I’ve retained the emphasis on the kernel’s role in a Linux system. This
material has proven popular, and you probably interact with the kernel
more than you realize.
I’ve added a new chapter introducing virtualization. Although Linux
has always been popular on virtual machines (such as cloud services), that
type of virtualization lies outside the scope of this book, because the way
the system operates on a virtual machine is almost the same as on “bare
metal” hardware. So, the discussion here primarily focuses on decipher-
ing the terminology you’ll encounter. However, containers have gained in
popularity since the second edition was published, and they also fit here,
because they basically consist of a bunch of Linux features like the ones
described throughout the rest of the book. Containers make heavy use of
cgroups, which also get new treatment in this third edition.
Other subjects (not necessarily related to containers) I happily expanded
on are the Logical Volume Manager, the journald logging system, and IPv6
in the networking material.

Preface xxiii
Though I’ve added a significant amount of content, the book is still a
reasonable size. I want to provide the information you need to get on the
fast track, and that includes explaining certain details along the way that
can be hard to grasp, but I don’t want you to have to become a weightlifter
in order to pick up this book. Once you master the important subjects here,
you should have no trouble seeking out and understanding more details.
The first edition included historical information that I removed later to
improve focus. If you’re interested in Linux and how it relates to the history
of Unix, pick up Peter H. Salus’s The Daemon, the Gnu, and the Penguin (Reed
Media Services, 2008). It does a great job of explaining how the software we
use has evolved over time.

A Note on Terminology
The names of certain operating system elements have caused a fair amount
of debate historically—even the word Linux itself. Should it be “Linux,” or
should it be “GNU/Linux” to reflect that the operating system also contains
pieces from the GNU Project? Throughout this book, I’ve tried to use the
most common, least awkward names possible.

xxiv Preface
1
THE BIG PICTURE

At first glance, a contemporary operating


system such as Linux is very complicated,
with a dizzying number of pieces simultane-
ously running and communicating. For exam-
ple, a web server can talk to a database server, which
could in turn use a shared library that many other pro-
grams use. How does all of this manage to work, and
how can you make sense of any of it?
The most effective way to understand how an operating system works
is through abstraction—a fancy way of saying that you can ignore most of
the details that make up a piece that you’re trying to understand, and con-
centrate instead on its basic purpose and operation. For example, when
you ride in a car, you normally don’t need to think about details such as the
mounting bolts that hold the motor inside the car or the people who build
and maintain the road upon which the car drives. All you really need to
know is what the car does (transports you somewhere else) and a few basics
about how to use it (how to operate the door and seat belt).
This level of abstraction might work if you’re just a passenger in the car.
But if you also need to drive it, you have to dig deeper and break up your
abstraction into a few parts. You now expand your knowledge in three areas:
the car itself (such as its size and capabilities), how to operate the controls
(steering wheel, accelerator pedal, and so on), and the features of the road.
Abstraction can be a great help when you’re trying to find and fix prob-
lems. For example, let’s say you’re driving a car and the ride is rough. You
can quickly assess the three basic car-related abstractions just mentioned to
determine the source of the problem. It should be fairly easy to eliminate
the first two abstractions (your car or the way you’re driving) if neither is the
issue, so you can narrow the problem down to the road itself. You’ll probably
find that the road is bumpy. Now, if you want, you can dig deeper into your
abstraction of the road and find out why the road has deteriorated or, if the
road is new, why the construction workers did a lousy job.
Software developers use abstraction as a tool when building an oper-
ating system and its applications. There are many terms for an abstracted
subdivision in computer software—including subsystem, module, and package—
but we’ll use the term component in this chapter because it’s simple. When
building a software component, developers typically don’t think much about
the internal structure of other components, but they do consider other
components they can use (so that they don’t have to write any additional
unnecessary software) and how to use them.
This chapter provides a high-level overview of the components that make
up a Linux system. Although each one has a tremendous number of technical
details in its internal makeup, we’re going to ignore these details and concen-
trate on what the components do in relation to the whole system. We’ll look
at the details in subsequent chapters.

1.1 Levels and Layers of Abstraction in a Linux System


Using abstraction to split computing systems into components makes things
easier to understand, but it doesn’t work without organization. We arrange
components into layers or levels, classifications (or groupings) of compo-
nents according to where the components sit between the user and the
hardware. Web browsers, games, and such sit at the top layer; at the bottom
layer we have the memory in the computer hardware—the 0s and 1s. The
operating system occupies many of the layers in between.
A Linux system has three main levels. Figure 1-1 shows these levels
and some of the components inside each level. The hardware is at the base.
Hardware includes the memory as well as one or more central processing
units (CPUs) to perform computation and to read from and write to memory.
Devices such as disks and network interfaces are also part of the hardware.
The next level up is the kernel, which is the core of the operating system.
The kernel is software residing in memory that tells the CPU where to look
for its next task. Acting as a mediator, the kernel manages the hardware
(especially main memory) and is the primary interface between the hard-
ware and any running program.

2 Chapter 1
Processes—the running programs that the kernel manages—collectively
make up the system’s upper level, called user space. (A more specific term
for process is user process, regardless of whether a user directly interacts with
the process. For example, all web servers run as user processes.)

User Processes

Graphical User Interface Servers Shell

Linux Kernel

System Calls Process Management Memory Management

Device Drivers

Hardware

Processor (CPU) Main Memory (RAM) Disks Network Ports

Figure 1-1: General Linux system organization

There is a critical difference between how the kernel and the user pro-
cesses run: the kernel runs in kernel mode, and the user processes run in
user mode. Code running in kernel mode has unrestricted access to the pro-
cessor and main memory. This is a powerful but dangerous privilege that
allows the kernel to easily corrupt and crash the entire system. The memory
area that only the kernel can access is called kernel space.
User mode, in comparison, restricts access to a (usually quite small) sub-
set of memory and safe CPU operations. User space refers to the parts of main
memory that the user processes can access. If a process makes a mistake and
crashes, the consequences are limited and can be cleaned up by the kernel.
This means that if your web browser crashes, it probably won’t take down the
scientific computation that has been running in the background for days.
In theory, a user process gone haywire can’t cause serious damage to the
rest of the system. In reality, it depends on what you consider “serious dam-
age,” as well as the particular privileges of the process, because some pro-
cesses are allowed to do more than others. For example, can a user process
completely wreck the data on a disk? With the correct permissions, yes—and
you might consider this to be fairly dangerous. There are safeguards to pre-
vent this, however, and most processes simply aren’t allowed to wreak havoc
in this manner.

The Big Picture 3


NOTE The Linux kernel can run kernel threads, which look much like processes but have
access to kernel space. Some examples are kthreadd and kblockd.

1.2 Hardware: Understanding Main Memory


Of all of the hardware on a computer system, main memory is perhaps the
most important. In its rawest form, main memory is just a big storage area
for a bunch of 0s and 1s. Each slot for a 0 or 1 is called a bit. This is where the
running kernel and processes reside—they’re just big collections of bits. All
input and output from peripheral devices flows through main memory, also
as a bunch of bits. A CPU is just an operator on memory; it reads its instruc-
tions and data from the memory and writes data back out to the memory.
You’ll often hear the term state in reference to memory, processes, the
kernel, and other parts of a computer system. Strictly speaking, a state is a
particular arrangement of bits. For example, if you have four bits in your
memory, 0110, 0001, and 1011 represent three different states.
When you consider that a single process can easily consist of millions
of bits in memory, it’s often easier to use abstract terms when talking about
states. Instead of describing a state using bits, you describe what something
has done or is doing at the moment. For example, you might say, “The pro-
cess is waiting for input” or, “The process is performing Stage 2 of its startup.”

NOTE Because it’s common to refer to the state in abstract terms rather than to the actual
bits, the term image refers to a particular physical arrangement of bits.

1.3 The Kernel


Why are we talking about main memory and states? Nearly everything that
the kernel does revolves around main memory. One of the kernel’s tasks is to
split memory into many subdivisions, and it must maintain certain state infor-
mation about those subdivisions at all times. Each process gets its own share
of memory, and the kernel must ensure that each process keeps to its share.
The kernel is in charge of managing tasks in four general system areas:
Processes  The kernel is responsible for determining which processes
are allowed to use the CPU.
Memory  The kernel needs to keep track of all memory—what is cur-
rently allocated to a particular process, what might be shared between
processes, and what is free.
Device drivers   The kernel acts as an interface between hardware
(such as a disk) and processes. It’s usually the kernel’s job to operate
the hardware.
System calls and support   Processes normally use system calls to com-
municate with the kernel.
We’ll now briefly explore each of these areas.

4 Chapter 1
NOTE If you’re interested in the detailed workings of a kernel, two good textbooks are
Operating System Concepts, 10th edition, by Abraham Silberschatz, Peter B.
Galvin, and Greg Gagne (Wiley, 2018), and Modern Operating Systems, 4th
edition, by Andrew S. Tanenbaum and Herbert Bos (Prentice Hall, 2014).

1.3.1 Process Management


Process management describes the starting, pausing, resuming, scheduling,
and terminating of processes. The concepts behind starting and terminat-
ing processes are fairly straightforward, but describing how a process uses
the CPU in its normal course of operation is a bit more complex.
On any modern operating system, many processes run “simultane-
ously.” For example, you might have a web browser and a spreadsheet open
on a desktop computer at the same time. However, things are not as they
appear: the processes behind these applications typically do not run at
exactly the same time.
Consider a system with a one-core CPU. Many processes may be able to
use the CPU, but only one process can actually use the CPU at any given
time. In practice, each process uses the CPU for a small fraction of a second,
then pauses; then another process uses the CPU for another small fraction
of a second; then another process takes a turn, and so on. The act of one pro-
cess giving up control of the CPU to another process is called a context switch.
Each piece of time—called a time slice—gives a process enough time for
significant computation (and indeed, a process often finishes its current
task during a single slice). However, because the slices are so small, humans
can’t perceive them, and the system appears to be running multiple pro-
cesses at the same time (a capability known as multitasking).
The kernel is responsible for context switching. To understand how this
works, let’s think about a situation in which a process is running in user
mode but its time slice is up. Here’s what happens:

1. The CPU (the actual hardware) interrupts the current process based on
an internal timer, switches into kernel mode, and hands control back to
the kernel.
2. The kernel records the current state of the CPU and memory, which
will be essential to resuming the process that was just interrupted.
3. The kernel performs any tasks that might have come up during the
preceding time slice (such as collecting data from input and output, or
I/O, operations).
4. The kernel is now ready to let another process run. The kernel analyzes
the list of processes that are ready to run and chooses one.
5. The kernel prepares the memory for this new process and then pre-
pares the CPU.
6. The kernel tells the CPU how long the time slice for the new process
will last.
7. The kernel switches the CPU into user mode and hands control of the
CPU to the process.

The Big Picture 5


Discovering Diverse Content Through
Random Scribd Documents
assistant being Midshipman Matiuschkin. Both parties did good
survey work, but neither made any striking discovery. Anjou reached
76° 36´ to the north of Kotelnoi; Wrangell reached 72° 2´ (north-
east of the Bear Islands, one hundred and seventy-four miles out on
the sea from the great Baranoff rock), beyond which progress was
impossible owing to the thinness of the ice, which was covered with
salt water.
Wrangell had many perilous experiences. In his fourth journey over
the sea the ice broke up around him and he found himself on a floe
with a labyrinth of water lanes hemming him in on every side and a
storm coming on from the westward. The storm rapidly increased in
fury, and the masses of ice around him were soon dashing against
each other and breaking in all directions. On the floe, which was
tossing to and fro on the waves, he gazed in painful inactivity on the
conflict, expecting every moment to be swallowed up. For three long
hours he had remained unable to move, the mass of ice beneath him
holding together, when it was caught by the storm and hurled
against a large field of ice. The crash was terrific, as it was shattered
into little pieces. At that dreadful moment, when escape seemed
impossible, he was saved by the impulse of self-preservation.
Instinctively the party sprang on to the sledges and urged the dogs
to full speed, and as hard as they could gallop they skimmed across
the yielding fragments to the field on which they had been stranded,
and safely reached a stretch of firmer ice, where the dogs ceased
running among the hummocks, conscious that the danger was past.
But it is not so much for adventures like this that his account of his
work is of continuing interest as for the abundance of its notes and
reflections on the country and its life and climate. Once, for instance,
when on the Baranicha he was fortunate enough to witness a
migration of reindeer. "I had hardly finished the observation," he
says, "when my whole attention was called to a highly interesting,
and to me a perfectly novel, spectacle. Two large migrating bodies of
reindeer passed us at no great distance. They were descending the
hills from the north-west and crossing the plain on their way to the
forests, where they spend the winter. Both bodies of deer extended
further than the eye could reach, and formed a compact mass,
narrowing towards the front. They moved slowly and majestically
along, their broad antlers resembling a moving wood of leafless
trees. Each body was led by a deer of unusual size, which my guides
assured me was always a female. One of the herds was stealthily
followed by a wolf, who was apparently watching for an opportunity
of seizing any one of the younger and weaker deer which might fall
behind the rest, but on seeing us he made off in another direction.
The other column was followed at some distance by a large black
bear, who, however, appeared only intent on digging out a mouse's
nest every now and then, so much so that he took no notice of us.
We had great difficulty in restraining our two dogs, but happily
succeeded in doing so; their barking, or any sound or motion on our
part, might have alarmed the deer, and by turning them from their
course, have proved a terrible misfortune to the hunters, who were
awaiting their passage, on which they are entirely dependent for
support. We remained for two hours whilst the herds of deer were
passing by, and then resumed our march."
The way in which the deer are dealt with by the hunters was seen
by Matiuschkin when despatched by Wrangell to survey the Anyui.
"The true harvest, which we arrived just in time to see, is in August
or September, when the reindeer are returning from the plains to the
forests. They are then healthy and well fed, the venison is excellent,
and as they have just acquired their winter coats the fur is thick and
warm. The difference of the quality of the skins at the two seasons
is such, that whilst an autumn skin is valued at five or six roubles, a
spring one will only fetch one or one and a half roubles. In good
years the migrating body of reindeer consists of many thousands;
and though they are divided into herds of two or three hundred
each, yet the herds keep so near together as to form only one
immense mass, which is sometimes from thirty to seventy miles in
breadth. They always follow the same route, and in crossing the
river near Plotbischtsche, they choose a place where a dry valley
leads down to the stream on one side, and a flat sandy shore
facilitates their landing on the other side. As each separate herd
approaches the river, the deer draw more closely together, and the
largest and strongest takes the lead. He advances, closely followed
by a few of the others, with head erect, and apparently intent on
examining the locality. When he has satisfied himself, he enters the
river, the rest of the herd crowd after him, and in a few minutes the
surface is covered with them. Then the hunters, who have been
concealed to leeward, rush in their light canoes from their hiding-
places, surround the deer, and delay their passage, whilst two or
three chosen men armed with short spears dash into the middle of
the herd and despatch large numbers in an incredibly short time; or
at least wound them so, that, if they reach the bank, it is only to fall
into the hands of the women and children. The office of the
spearman is a very dangerous one. It is no easy thing to keep the
light boat afloat among the dense crowd of swimming deer, which,
moreover, make considerable resistance; the males with their horns,
teeth, and hind legs, whilst the females try to overset the boat by
getting their fore-feet over the gunwale; if they succeed in this the
hunter is lost, for it is hardly possible that he should extricate himself
from the throng; but the skill of these people is so great that
accidents very rarely occur. A good hunter may kill a hundred or
more in less than half an hour. When the herd is large, and gets into
disorder, it often happens that their antlers become entangled with
each other; they are then unable to defend themselves, and the
business is much easier. Meanwhile the rest of the boats pick up the
slain and fasten them together with thongs, and every one is
allowed to keep what he lays hold of in this manner. It might seem
that in this way nothing would be left to requite the spearmen for
their skill, and the danger they have encountered; but whilst
everything taken in the river is the property of whoever secures it,
the wounded animals which reach the bank before they fall, belong
to the spearman who wounded them. The skill and experience of
these men are such that in the thickest of the conflict, when every
energy is taxed to the uttermost, and their life is every moment at
stake, they have sufficient presence of mind to contrive to measure
the force of their blows so as to kill the smallest animals outright,
but only to wound the larger and finer ones, so that they may be
just able to reach the bank. Such proceeding is not sanctioned by
the general voice, but it seems nevertheless to be almost always
practised. The whole scene is of a most singular and curious
character, and quite indescribable. The throng of thousands of
swimming reindeer, the sound produced by the striking together of
their antlers, the swift canoes dashing in amongst them, the terror
of the frightened animals, the danger of the hunters, the shouts of
warning advice or applause from their friends, the blood-stained
water, and all the accompanying circumstances, form a whole which
no one can picture to himself without having witnessed the scene."

REINDEER

The tundra has no more characteristic animal than the reindeer. Over
the mossy hillocks and the matted tops of the dwarf birches he runs,
or through the rivers and lakes he swims, with his broad-hoofed,
spade-like feet never at a loss to find a footing. In the long winter he
is protected by his thick skin against the influence of the cold, and is
seldom at starvation point, as he digs for food in the deepest snow,
and is by no means particular what he eats; and in the short
summer he is in luxurious ease, for the tundra, as we have seen, is
not always as bad as it is painted. In exposed places near the coast
it is little else than gravel beds interspersed with patches of peat and
clay, with scarcely a rush or a sedge to break the monotony, but by
far the greater part of it is a gently undulating plain, broken up by
lakes, rivers, swamps, and bogs; the lakes with patches of green
water-plants, the rivers flowing between sedges and rushes, the
swamps the breeding haunts of ruffs and phalaropes, the bogs
dotted with the white fluffy seeds of the cotton-grass. Almost
everywhere the birds are in noticeable numbers, among the
commonest being the golden plover (who wears the tundra colours),
the bluethroat, the fieldfare, the whooper swan, and the ducks and
divers—particularly the divers—and, among the birds of prey, the
falcons and the rough-legged buzzards, which, with the owls, find
such abundant provision in the lemmings that migrate in myriads
compared with which the reindeer troops are insignificant.
"The groundwork of all this variegated scenery," says Seebohm, "is
more beautiful and varied still—lichens and mosses of almost every
conceivable colour, from the cream-coloured reindeer-moss to the
scarlet-cupped trumpet-moss, interspersed with a brilliant alpine
flora, gentians, anemones, saxifrages, and hundreds of plants, each
a picture in itself, the tall aconites, both the blue and yellow species,
the beautiful cloudberry, with its gay white blossom and amber fruit,
the fragrant Ledum palustre and the delicate pink Andromeda
polifolia. In the sheltered valleys and deep water-courses a few
stunted birches, and sometimes large patches of willow scrub,
survive the long severe winter, and serve as cover for willow-grouse
or ptarmigan. The Lapland bunting and red-throated pipit are
everywhere to be seen, and certain favoured places are the
breeding-grounds of plovers and sandpipers of many species. So far
from meriting the name of Barren Ground, the tundra is for the most
part a veritable paradise in summer. But it has one almost fatal
drawback—it swarms with mosquitoes."

OSTIAK MAN
SAMOYED MAN

The beauty of the tundra is, however, transient and skin deep; it is
only such plants as can live in the soil that thaws that survive.
Wherever the ground is dug into, ice is sure to be reached; in fact, it
may be said that ice is one of the rocks of the subsoil, and in some
places these strata of ice that never melts have been found to be
three hundred feet thick—ice that has remained in block since the
mammoths got into cold storage in it ages ago, for otherwise they
would not have lasted intact in skin and flesh as many have done,
like the very first discovered in a complete state, that chipped out by
Adams in 1807.
In such a climate, whose winter terrors are only too prominent, all
along the north of Siberia live the ancient peoples driven towards
the sea by those mighty movements from the land of the Turk and
Mongol which, north and south, east and west, flooded Europe and
Asia with invaders—Ostiaks and Samoyeds west of Chelyuskin;
Yakuts, Chukches, and others to the east of it, the descriptions of
whose unpleasant manners and customs appear to be written with a
view to showing how curiously local are the laws of health. One may
well ask, as Wrangell did, why they should remain in so dreary a
region and take life so contentedly. And the answer may be that they
might go further north and fare worse, as their predecessors in the
eastern section would seem to have done. Once, according to the
legend, there were more hearths of the Omoki on the shores of the
Kolyma than there are stars in the clear sky, and these Omoki, or
some other departed race, appear to have left as their traces the
remains of the timber forts and the tumuli that are found on the
coast, especially near the Indiyirka, and the huts of earth and stones
and bones found all along from Chelagskoi to the straits, similar
remains of a departed people now existing in the Parry Islands, over
a thousand miles away. According to another legend of more recent
date, there was an intervening land, the land that Wrangell went to
seek and the Jeannette went to winter at, and the supposed site of
which she drifted through, in her last and longest imprisonment in
the ice.
The Jeannette was the old Pandora, bought from Sir Allen Young by
James Gordon Bennett, and accepted by and fitted out, officered,
and manned under the orders of the Navy Department of the United
States, her commander being Lieutenant George Washington De
Long. She left San Francisco on the 8th of July, 1879, and two
months afterwards had been run into the pack and was fast in the
ice off Herald Island, drifting to her doom. Her route, in the main,
was north-westerly, with many complicated loops, at first at the rate
of half a mile a day, then at two miles, then at three, showing that
the current from Bering Strait had been reinforced by some other
current as she went further west, and, from its direction, there
seemed to be land to the northward which was never sighted.
Wrangell Land, passed to the south, proved to be not a continent
but a small island. No other land was seen for a monotonous twenty
months, and then, in May, 1881, the ship drifted, stern first, past
that sighted by Hedenström from New Siberia, which was found to
consist of two islands, to be henceforth known as Jeannette and
Henrietta. On the 12th of June, in latitude 77° 14´ 57˝, the
Jeannette was crushed and sank, her fore yardarms breaking
upwards as she slipped down through the rift in the pack, and a
start was made for the Siberian Islands over the ice; but the drift
had taken the party to 77° 36´, before they got on their proper
course, and after a most laborious journey, lasting up to the 28th of
July, they were safe ashore on the land sighted by Sannikof from
Thaddeus, which De Long named Bennett Island.
Bennett Island was left on the 7th of August, the party of thirty-
three being in three boats, thirteen under De Long in the first cutter,
ten under Lieutenant Chipp in the much smaller second cutter, and
ten, under Engineer George W. Melville, whose skill and
resourcefulness had been conspicuous throughout, were given the
whale-boat, the most suitable of the three. Sail was made for
Thaddeus Island, which was reached in safety; after a halt of some
days it was left on the 31st of August. Then Kotelnoi Island was
reached and rested at; then the boats made for Semonovski, which
was left on the 12th of September.
The same day a gale came on in which the first cutter had great
difficulty in keeping afloat, the second cutter disappeared never to
be heard of again, and the whale-boat, behaving excellently, went
off before the wind straight for the continent to reach in safety one
of the eastern mouths of the Lena, up which Melville arrived at a
Russian village on the 26th of September. De Long's party ran their
boat aground in shallow water, on the 17th of September, and rafted
and waded ashore to one of the most inhospitable spots on the
globe. Heavily laden they made their way down the dreary delta,
toiling through the snow, delayed by the tributaries which were not
frozen over hard enough to bear, hampered by sickness and
disablement, and finally dying one by one of starvation.
On the 9th of October De Long sent two of the seamen, Nindemann
and Noros, ahead in search of relief. They had no food but what
they could find, and on the second day out their dinner consisted of
a little willow tea and a burnt boot sole. Next morning they burnt
another sole of a boot, and they spent the day struggling through a
morass in drifting snow, crossing streams of all sizes, and halting for
the night in so high a wind that they were unable to light a fire and
took refuge in a hole in the snow from which they emerged with
difficulty in the morning, owing to the wind having piled up the snow
against the opening. At the end of the third day they reached a
deserted hut in which were some deer bones, which they grilled and
tried to eat, and in the morning a gale was blowing and the wild
drifting snow was so thick that they had to remain where they were
and continue their diet of charred bones and willow tea.
Next day, Thursday, the 13th of October, they began against a
strong head wind. In the afternoon they sighted a hut on the west
bank of the river. "They had seen one in the morning, but had in
vain attempted to cross the ice to it. Now they tried to reach this,
but were turned back by the brittle ice. They kept it in sight as they
moved southward, and made another attempt to cross the ice, but it
broke and they came back. Then they saw that there was no further
progress possible to the southward on that side of the water, and
they returned to the ice. It broke again, but they kept on. They went
in up to their waists, but managed to pull themselves up on the
stronger ice." The wind was blowing against them and the ice was
like glass, so that they were driven back. They looked about for ice
which had been roughened by the ripples beneath, and finding some
they succeeded at length in reaching the other side, where were two
wooden crosses beneath a bank, which rose fifty feet above them.
They pulled themselves up the bank, but when they came to the hut
which they had kept in sight they found it a ruin nearly full of snow.
"While Noros was trying to make a place in it for shelter, Nindemann
saw a black object farther along to the south and went to it. It was a
small peaked hut without a door, but large enough to hold two men.
There were some fresh wood shavings outside the hut and higher up
on the hill two boxes. On going to them Nindemann found them old
and decayed, and he began to break one of them open. When he
had ripped off the top he discovered that there was another box
enclosed; breaking into it he found a dead body, and hastily left it.
Doubtless the two crosses below on the river bank were memorials
of the two beings left high up above the reach of the floods."
In the small hut they found a sort of floor, the boards of which they
pulled up for firewood, and in a hole beneath was a box in which
were a couple of fish and two fish heads; and, as these were
discovered, a lemming came out of another hole and was promptly
caught. On the lemming, roasted on the ramrod, and the fishes,
which were so decayed that they dropped apart as they were
handled, they made their meal for that day. Next day the snowstorm
was so heavy that they were driven back here after striving in vain
to make headway. On the Saturday, still without food, they rested for
the night in a fissure in the river bank, where as a last resource
Nindemann cut a piece off his sealskin trousers and soaked it in
water and burnt it to a crust. Their breakfast consisted of the
remains of this toasted sealskin. During the day they saw a crow
flying across the river and in among the hills, and, as the crow in
these regions is rarely found away from the haunts of men,
Nindemann decided to cross the river in the hope of meeting with
either natives or game on the other side. When darkness came on
no shelter was discoverable, and so, after a meal of more sealskin
and hot water, they went to rest in a hole in the snow. Next day,
during which they recrossed the river, their experiences were similar
and the end the same.
On Tuesday the 18th, after a terrible day, they came upon a hut with
a pile of wood close by, which proved to be sledges, and these they
broke up, as there was no other firing. Next day as they were
struggling on they reached a place where there were three huts, in
one of which was a half-kayak and in it was some blue mouldy fish;
and here, attacked by dysentery, they remained until the Saturday,
unable to go any further. About noon there was a noise outside like
a flock of geese sweeping by. Nindemann, looking through the crack
of the door, saw something moving which he took to be a reindeer,
and was going out with his rifle when the door opened and a man
entered, who promptly fell on his knees when he caught sight of the
gun. Nindemann threw the rifle into a corner and, trying to make
friends with the man by signs, offered him some of the fish, which
the man by an emphatic gesture pronounced not fit to eat. After
some more of the sign language it was clear that the native had no
food with him, and holding up three or four fingers to show that he
would return in so many hours or days he drove off. About six
o'clock in the evening, while they were preparing their fish dinner,
the visitor returned with two other men, one of whom brought in a
frozen fish which he skinned and sliced, and while the sailors were
eating it—the first healthy meal they had had for weeks—the natives
invited them to accompany them, and brought in deerskin coats and
boots and finally got them into the sledges and drove off to the
westward for about fifteen miles. Here there were two tents, and
Nindemann was taken into one, Noros into the other, and both were
well looked after, the natives doing their very best to get them well.
This was intelligible on both sides, for the language of kindness is
universal, but as the sailors knew not the language of their hosts,
and the natives knew not the language of their guests, the difficulty
of being understood by each other was great, and the delivery of the
urgent message in signs was almost impossible. Nindemann did his
best; he appealed to the man who seemed to be the head of the
party, and drawing in the snow a map of the places where he had
been, with every combination of signs he could think of, he tried to
explain what he wanted. That he succeeded to a certain extent was
clear, though he did not think so at first, for the natives loaded up
their sledges, twenty-seven in number, with reindeer meat and skins
and fish, and struck their tents, and, with over a hundred head of
deer harnessed up, started for the south. At noon, when the deer
were resting, the man for whom the map had been drawn in the
snow took Nindemann to where he could show him a prominent
landmark, and asked by signs if that was where he had left his
friends. And on learning by signs that it was further to the north, he
shook his head as if sorry, and resumed his journey to the south.
During the next day they reached Ku Mark Surka, where there were
a number of natives who were much interested in the new-comers,
and again the sailors used every effort to deliver their message.
Immediately after breakfast on the morning of the 25th, Nindemann
began talking to these people in signs and pantomime. Soon one of
them showed that he had an idea of where the sailors came from,
for he spoke to one of the boys, who ran off and returned with a
model of a Yakutsk boat. Then they gathered round and evidently
asked if the ship was anything like it. And in answer, Nindemann
took up some sticks and placed three of them in the boat to show
that his ship had three masts, and then he fastened smaller sticks
across to show that she had yards, which seemed to surprise them
greatly. Then he made a funnel out of wood and put it in position,
and pointed to the fire and smoke to show that she was a steamer,
and then he cut out a propeller with his knife and put it where the
rudder was to show that she was a screw. Continuing his work he
soon chipped out so many small boats to show how many she had;
and then, signing to one of the men to get him two pieces of ice, he
showed them how the ship had been crushed. Pointing to the
northward he tried to tell them that the ship had been crushed up
there; and then he put away the ship and kept only three of the little
boats to tell that part of the story, and in the boats he put so many
sticks to represent the number of men in each. When he had done
this one of the men pointed to a dog that was looking on and asked
if the ship had any, whereupon the sailor counted on his fingers to
show there were about forty, and by pantomime explained that they
had been shot. This being evidently understood, Nindemann drew a
chart of the coast-line, and imitating a gale of wind showed that the
boat he came from went to the land at a certain point and that he
knew nothing of the others. Then he went on to show how they had
all left the boat, waded ashore and walked along the river-bank, and
he marked the huts where they had stopped, and then he indicated
where one of the men had died and been buried in the river. This
was understood, for all the audience shook their heads as if to say
how sorry they were. But when he tried to tell them that he had left
the captain two days afterwards and had been so many days on the
way to ask for help, they showed that they either did not or would
not understand; and really it was not easy to make such a matter
clear.
Next day Nindemann made another attempt to get them to
understand the one essential, urgent fact that help was needed, or
the men would die; but no, he could not do it. On the Thursday,
despairing of the hopelessness of his task and the helplessness of
his companions, he broke into tears and groans, and a woman in the
hut took pity on him and spoke earnestly to one of the men, who
came and said something about a commandant. Then the sailor, who
had picked up a few words, asked him to take him to Bulun, to
which the man replied by again saying commandant and holding up
five or six fingers. Late in the evening there arrived a tall Russian,
whom Nindemann supposed to be the commandant and addressed
in English, but he was a Russian exile who could not understand
him, though he seemed to know something about the matter, for in
what he said he clearly mentioned Jeannette and Americansk.
Nindemann tried him in German, but at this he shook his head. Then
Nindemann showed him the chart given him by De Long, which the
Russian evidently did not understand, though he said something that
sounded like St. Petersburg and telegrams. While this apparently
hopeless conversation was going on Noros was busy steadily writing
out a note that the two sailors had drawn up, and the tall Russian—
who we shall see was really a most intelligent man—giving over his
talk with Nindemann in despair, coolly picked this up and put it in his
pocket, and notwithstanding the protest of the Americans, walked
off with it. In the morning he came in and gave them to understand
that he was going to Bulun, and that they were to follow, and soon
afterwards the natives fitted them out with clothing and boots and
food and sent them off on a sledge. At Bulun they were taken to the
commandant, who, after a little sign language from Nindemann,
showed that he understood, and said something about a telegram.
The sailors jumped at the idea, and one of them dictated to the
other a despatch to the American Minister at St. Petersburg. This the
Russian took, explaining that the captain should have it next day.
Who the captain was the sailors could not make out; but three days
afterwards, that is on the 3rd of November, while Nindemann lay on
the bed and Noros was sitting on the table, a man came in dressed
in fur.
"My God, Mr. Melville!" said Noros, recognising him as soon as he
spoke. "Are you alive? We thought that the whale-boats were all
dead!"
The exile had handed the note to Melville, whom he knew as the
captain, and his difficulty in understanding the sailors had been in
their speaking of one boat while he had only seen the other. The
whale-boat crew had reached a village opposite to where he lived,
and he had agreed to take them to Bulun, and he was on his way
there to arrange for their transport when he heard of the sailors.
Like a sensible man he ordered the men to be sent to Bulun, and
had hurried there, made his arrangements with the commandant
and returned to Melville, who, seeing the urgency of the case as
soon as he read the letter, had started at once, leaving his party to
follow.
Melville, as soon as possible, went off along the track of the two
sailors, who were too weak to go with him, and eventually found the
chronometer and the log-books and other records; but the winter
was too far advanced for him to do more, and he had to return,
after a journey of over six hundred miles, to try again in the spring.
Then, accompanied by Nindemann, he went north, and came upon
the bodies of the commander and those who had perished with him,
and three or four feet behind De Long, as if he had tossed it over his
shoulder, lay the journal in which the last page was but a chronicle
of death after death.
This chapter must conclude with another tragedy. In 1885 Dr. Bunge
and Baron Toll made some important investigations in the
neighbourhood of the mouth of the Yana; and next year Bunge
among the fossils of Liakhoff Island found not only mammoth and
rhinoceros, but horse, musk-ox and deer, and two new species of ox.
To these Toll, after discovering that there were flourishing trees on
Kotelnoi in the time of the mammoth—nearly two hundred miles
north of their present limit—added frozen carcases of musk-ox and
rhinoceros, and bones of antelope and tiger.
In 1902 Toll, pushing his geological researches further north,
reached Bennett Island, where he collected bones of the mammoth
and other recent mammals, while the main mass of the plateau he
identified as of Cambrian age. These discoveries he included in the
record announcing his intention of leaving for Kotelnoi, which was
found in 1904 by the expedition sent to his relief, for he was never
seen alive again.
CHAPTER VII
BERING STRAIT

Native stories of the distant continent—The Russians in Kamchatka—Bering's


expedition—The difficulties of his task—Builds a vessel and reaches
Kamchatka—Builds another vessel and discovers the strait named after him
by Captain Cook—His second expedition—Spangberg's voyage to Japan—
Bering reaches the American coast—His shipwreck and death—The
influence of the sea-otter and the fur-seal on geographical discovery—The
Arctic voyage of Captain Cook—Clerke's voyage—Beechey's voyage—Point
Barrow reached by the barge of the Blossom—Kellett's voyage in the Herald
—Boat expedition to Hudson Bay—Kellett reaches 72° 51´—Landing on
Herald Island—Kellett sights Wrangell Island—Berry in the Rodgers explores
Wrangell Island—He reaches 73° 44´—Frederick Whymper and W. H. Dall
ascend the Yukon.

R
umours of land over against the far corner of Siberia had
reached the Russians for years, and many were the legends of
those who had seen these lands from the cliffs, or had been on
the ice to look at them more closely, or had gone away to them and
never come back. There was, for instance, the old legend of
Kraechoj, who believed he had found safe shelter at Irkaipii from the
Chukche vengeance, but the Chukche made his way into the
stronghold and killed Kraechoj's son, whereupon Kraechoj escaped
by letting himself down with thongs to the boat and fled to the land
whose mountains can be seen in clear sunshine from Cape Yakan;
and there he was among his people who had left Asia before him.
And among the official documents was the statement made by the
Chukches when they went to Anadyrskoi Ostrog to acknowledge the
dominion of the Russians, that "The Noss is full of rocky mountains,
and the low grounds consist of land covered with turf. Opposite to it
lies an island, within sight of it, of no great extent, and void of
wood. It is inhabited by people who have the same aspect as the
Chukche, but are quite a different nation, and speak their own
language, though they are not numerous. It is half a day's voyage
with boats from the Noss to the island. There are no sables on the
island, and no other animals but foxes, wolves, and reindeer. Beyond
the island is a large continent that can be scarcely discerned from it,
and that only on clear days; in calm weather one may row over the
sea from the island to the continent, which is inhabited by a people
who in every particular resemble the Chukches. There are large
forests of fir, pine, larch, and cedar trees; great rivers flow through
the country and fall into the sea. The inhabitants have dwellings and
fortified places of abode environed with ramparts of earth; they live
upon wild reindeer and fish; their clothes are made of sable, fox,
and reindeer skins, for sables and foxes are there in great
abundance. The number of men in that country may be twice or
three times as many as that of the Chukches who are often at war
with them." That there was land in sight somewhere seemed clear,
but the reports differed in placing it all the way round from the north
to the east. Many were the vain attempts to reach it from the
northward-flowing rivers, and it was left to be found from the Pacific
side.
BERING STRAIT

When Atlassof, in 1697, took the first steps in the conquest of


Kamchatka the Russians were already known to the inhabitants.
Long before him Fedotof and a few comrades had made their way
into the country and intermarried with native women. They had
been held in great honour and almost deified as being evidently of a
superior race. For some time it was supposed that no human hand
could hurt them, but this belief was rudely shattered when two of
the demigods quarrelled and fought, and one wounding the other,
the blood flowed. That flow of blood was fatal, for the natives,
judging that they were but ordinary flesh, took an early opportunity
of wiping them out, the name of their leader being still traceable in
that of the Fedotcha River on the banks of which they had lived.
The Kamchadales had other tales to tell of visitors from the east and
south, and Atlassof himself discovered on the River Itcha a Japanese
who had been wrecked on the coast two years before, from whom
he learnt of islands innumerable. But there were no ships on the
Pacific coast of Siberia, and nothing in the way of discovery could be
done until 1714, when there arrived at Ochotsk a detachment of
sailors and shipwrights despatched thither overland. According to
one of the sailors, Henry Bush, a Dutchman, the carpenters built a
good durable vessel some fifty feet long which was ready for sea in
1716 when the first voyage was undertaken. The coast of
Kamchatka was made near the River Itcha, and sailing south they
reached the Kompakova, where they wintered and found the whale
that had in its body the harpoon of European workmanship marked
with Roman letters, mentioned by Scoresby. Bush returned to
Ochotsk in July, to be sent in the following year to discover the
Shantar Islands, and next year, 1718, the Kuriles; thus venturing into
the Pacific beyond Cape Lopatka.
The last of these expeditions was due to the direct order of Peter the
Great, who, knowing nothing of Deschnef, and finding the sea open
to the north, resolved on a voyage in that direction, his holograph
instructions to Admiral Apraxin being: "One or two boats with decks
to be built at Kamchatka, or at any other convenient place, with
which inquiry should be made relative to the northerly coasts, to see
whether they are not contiguous with America, since their
termination is not yet known." Peter died, and the Empress
Catherine, carrying out these instructions in their fullest meaning,
began her reign with an order for the expedition.
Veit Bering, Dane by birth and sailor by trade, had voyaged to the
Indies, east and west, and, like many other men of enterprise, had
entered the Russian service at Peter's invitation. He had served with
distinction in the Cronstadt fleet in the war against the Swedes, and,
being in good repute for his knowledge of ships and their handling,
was appointed to the command of the most remarkable Arctic
enterprise on record. Just as Nicholas ruled a line and ordered a
railway to be built there, so did Catherine in the same imperial way
order an exploring expedition, and it was done. But it meant building
the ship from the trees of the forest on the coast of the Pacific and
carrying the materials and stores—everything but the timber—right
across the Russian empire in the days when for thousands of miles
there were not even roads.

THE FACE OF THE FUR SEAL

Bering's lieutenants were Martin Spangberg and Alexei Tschirikof.


With them and the rest of the expedition he left St. Petersburg on
the 5th of February, 1725. During that year they got as far as the
Ilim, where they wintered. In the spring of 1726 they sailed down
the Lena to Yakutsk, where they parted company for a time owing to
the difficulties of the route to Ochotsk, the way not being passable in
summer with wagons, or in winter with sledges, on account of the
marshes and rocky ground. So Spangberg set out, working along the
rivers Aldan, Maia, and Judoma, with part of the provisions and
heavy naval stores, while Bering followed overland through
uninhabited country with more stores on horses, and Tschirikof
remained to collect still more and follow in the track of his
commander.
Bering reached Ochotsk first. Spangberg was frozen up in the
Judoma, and thence he walked to Ochotsk with the most necessary
materials; but he suffered so much from hunger on the way that he
had to support life by eating leather bags, straps, and shoes, and did
not reach Bering till the 1st of January, 1727, nearly two years after
leaving St. Petersburg. In the beginning of February he returned to
the Judoma and brought away about half of his lading, the other half
being left for a third journey, which he made from and to Ochotsk on
horses. Meanwhile Tschirikof was toiling along from Yakutsk, and did
not arrive to complete the party until the 30th of July.
On arrival Bering had to build a vessel to take his most necessary
naval stores and his shipbuilders across the sea of Ochotsk to
Bolscheretzkoi, which, in her, he reached on the 2nd of September.
From here he followed the shipwrights, who went on ahead to fell
the trees, taking with them the provisions and stores, over the
backbone of the isthmus and down the Kamchatka River to the
mouth, a distance of some two hundred miles, the journey being
very slow on account of the travelling being by dog-sledge. In short,
it was not until the 4th of April, 1728, that is, more than three years
after leaving St. Petersburg, that it was possible to put on the stocks
the vessel in which the voyage to the north was to be made. But she
took only three months to build, being launched on the 10th of July,
when she was named the Gabriel.
Laden with stores for forty men during a year's voyage, she put to
sea ten days afterwards, Bering keeping close to the coast so that
he could map it as he went. On the 10th of August he was off the
island of St. Lawrence, which he so named, as it was the day of that
saint. In a day or two he had passed the East Cape without seeing
the American coast, and had entered the Arctic Circle. And on the
15th he was well through the strait, out in the Arctic Ocean, in 67°
18´ off Serdze Kamen, a promontory behind which the coast trended
to the west, as the Chukches had told him it did; and he assumed,
and rightly so, though he had not gone far enough to prove it, that
there was no land connection between Asia and America.
Whereupon, as he had in his opinion accomplished his mission,
seeing no need for wintering in those parts, he put the Gabriel about
and was back in the Kamchatka River on the 20th of September,
after a voyage of seven weeks in a vessel that took three months to
build on a spot that took over three years to reach—the plan of
campaign being much the same as that in which a mountain
stronghold is advanced on across a desert, besieged for a few days,
and captured by assault.
THE ALEUTIAN ISLANDS

After wintering, Bering went off next year on a voyage due east in
search of reported land, but, after some hundred and thirty miles
out, he was blown back, and, rounding the south end of Kamchatka,
put in at the River Bolschaia; thence he crossed to Ochotsk, whence
he started for St. Petersburg, where he arrived after an absence of
five years. Catherine was dead and another empress reigned in her
stead, who was pleased and satisfied if no one else was, and the
21st of February, 1733, saw him starting again in the same laborious
fashion to arrange other voyages as part of a great scheme for the
exploration of Northern and North-eastern Asia. Some of these
expeditions on the north coast have already been mentioned;
Bering's particular task was to send Spangberg in search of Japan,
while he and Tschirikof, in separate ships, went eastward to America.
More stores and provisions went overland across Siberia than before;
Spangberg got again frozen up on the Judoma and had to continue
on foot to Ochotsk, where he found plenty of food owing to Bering
having sent on ahead, in case of any such trouble, a hundred
horses, each of them laden with meal. In June, 1738, Spangberg, in
two newly-built vessels and the Gabriel, was off to Japan, to reach
the Kuriles and return to winter in Kamchatka; but next year he
arrived there all well and found to his astonishment that the
Japanese knew as much about maps as he did. He was still more
astonished on his return to be told by those high in office at St.
Petersburg that he could not possibly have been there as they had
not got it on their maps where he said it was, and, consequently, he
was to go where he had been as soon as he could to make sure. He
started on this voyage of verification, but circumstances were
against him and he did not reach there; and his Japanese trip
remained discredited until the Russian geographers knew better. His
voyage thither had, however, used such a stock of provisions that it
was two years before the deficiency could be made up, and it was
actually the 4th of September, 1740, seven and a half years after
leaving St. Petersburg, when Bering, in the specially-built St. Peter,
and Tschirikof, in her sister the St. Paul, got off outward bound to
America.
In about three weeks they were at Awatcha Bay on the east of
Kamchatka, anchored in the fine harbour named Petropaulovsk after
the two ships, and here they had to stay for the winter, so that they
did not leave Russian territory until the 4th of the following June. A
few days out the ships were separated in a fog and storm, and the
St. Paul reached the American coast first, at Kruzof Island on the
western shore of Sitka Sound. The St. Peter three days afterwards,
on the 18th of July, drifted to the coast more to the northward, at
Cape St. Elias near the mighty mountain of that name. In this
neighbourhood amid much fog Bering stayed six weeks until he was
blown out to sea, when, his men beginning to die from scurvy, he
resolved to return to Kamchatka. It was a voyage of misfortune in a
continual downfall, the men in want, misery, and sickness,
continuously at work in the cold and wet, becoming fewer and fewer,
so that there were not enough to work the ship properly. It ended
on one of the Commander Islands by the vessel being lifted by the
sea clear over a reef into calm water. Bering died—the island is
named after him—and the survivors of the crew, building a boat
from the materials of the St. Peter, arrived at Petropaulovsk on the
27th of August, bringing with them a quantity of sea-otter skins,
which did more for discovery in those seas than any imperial
expedition.

DRIVING THE FUR SEAL

As the sable had brought about the conquest of Siberia, so did the
sea-otter lead to the seizure of the islands of the Bering Sea and the
coasts of Alaska. Three years after the return of the survivors of the
St. Peter, Nevodtsikof wintered on one of the Aleutian Islands, and
in a few years the fur-hunters were at their exterminating work over
the whole chain. In time the fur-seal attracted as much attention,
and, with Pribylov's discovery, in 1786, of its rookeries on the islands
named after him, the trade became of such increasing importance as
to endanger in our time the peace of the world. Every one has heard
of the wonderful haunts and habits of that strange eared seal which
seems to have come from the south through the tropics to breed in
the coldest limit of its range, now almost entirely on the Pribylovs
and the Commanders; how it is pursued in skin boats and every sort
of craft, and scared in long lines to slaughter by clapping of boards
and bones and waving of flags and opening and shutting of gingham
umbrellas, until it promises to become as extinct as Steller's sea-cow
or as rare as the sea-otter.
Following Bering on the way to the north came Captain James Cook,
in H.M.S. Resolution, who gave Bering's name to the strait. Cook
sighted Mount St. Elias in May, 1778, and, cruising slowly along the
coast with many discoveries and much accurate surveying, was off,
and named, Cape Prince of Wales, the western extremity of America,
on the 9th of August. He then crossed the strait and plied back until
on the 18th he sighted and named Icy Cape in 70° 29´. Close to the
edge of the ice, which was as compact as a wall, and seemed to be
ten or twelve feet high at the least, he sought persistently for a
passage through, but none was to be found; and after reaching 70°
6´ in 196° 42´ (163° 18´ W.) on the 19th, he turned westward to
the Asiatic coast, along which he went until he sighted and named
Cape North, as already stated. Then, blocked by ice, east, north, and
west, he returned, passing Cape Serdze Kamen (Bering's farthest)
and naming East Cape, confirming Bering's observation that it was
the most easterly point of Asia.
On Cook's death at Hawaii Captain Charles Clerke, of the
accompanying vessel H.M.S. Discovery, took command of the
expedition and carried out Cook's intention of making another effort
during the following year. The ice conditions were, however, worse.
The two ships found the ice block further south, and as impenetrable
as before, and Clerke's highest was 70° 33´ on the American side,
on the 19th of July. As it was Cook's last voyage, so it was Clerke's.
He was in a bad way with consumption, and continued his work in
the north, though, under the special circumstances and being in
command, he could at any time have given up the obviously
hopeless attempt and left for a more genial climate, in which he
would at least have had a chance of longer life; but, remaining at his
duty, he died at sea on the 22nd of August, and was buried at
Petropaulovsk.

FUR SEALS AT SEA

Captain Beechey, in H.M.S. Blossom, passed through the strait in


1826 when sent north from the Pacific with a view of meeting with
his old commander, Franklin, then on his second land journey.
Beechey took the ship to Icy Cape, whence on the 17th of August he
despatched the barge under the master, Thomas Elson, to survey
the coast to the north-eastward as far as he could go in three
weeks, there and back. Elson reached his farthest on the 25th at a
spit of land jutting out several miles from the more regular coast-
line, the width of the neck not exceeding a mile and a half, broadest
at its extremity, with several frozen lakes on it, and a village, whose
natives proved so troublesome that it was thought unsafe to land.
This was Point Barrow, in 71° 23´ 31˝, longitude 156° 21´ 30˝, the
northernmost land on the western half of the American continent. To
the eastward curved a wide bay—named Elson Bay by Beechey—the
shore-line of which joined on to the ice pack that encircled the
horizon. Here he was within a hundred and sixty miles of where
Franklin had turned back a week before. Though Beechey did not
meet Franklin he did most useful work in these parts, for by him the
whole coast was surveyed between Point Barrow and Point Rodney,
to the south of Prince of Wales Cape.
Franklin was also the cause of the appearance of the next British
expedition in the strait. This was in 1848, Captain Henry Kellett, in
H.M.S. Herald, with Commander Thomas Moore in H.M.S. Plover,
forming the western detachment of the first series of search
expeditions. There were three detachments, one to follow the
Erebus and Terror from the eastward, another under John
Richardson to descend the Mackenzie and search the northern coast,
the other coming in from the west to meet the ships should they
have made the passage. On this duty the Herald and Plover were
hereabouts for three seasons, the Plover wintering, the Herald going
south when the navigation closed.
In October, 1826, Beechey had buried a barrel of flour for Franklin
on the sandy point of Chamisso Island, ample directions for finding it
being cut and painted on the rock, and to call the attention of the
party to the spot the name of the Blossom was painted on the cliffs
of Puffin Island. When the Herald was at Chamisso Island in 1849
Captain Kellett searched for this flour and found it. A considerable
space was cleared round the cask, its chimes were freed, and, only
adhering to the sand by the two lower bilge staves, it required the
united strength of two boats' crews, with a parbuckle and a large
spar as a lever, to free it altogether. The sand was frozen so hard
that it emitted sparks with every blow of the pickaxe. The cask itself
was perfectly sound and the hoops good, and out of the 336 lb. of
flour which it contained, 175 lb. were as sweet and well tasted as
any he had with him; so good indeed was it that Captain Kellett gave
a dinner party, at which all the pies and puddings were made of this
flour.

THE PARKA OF THE ALASKAN INNUITS

(THE SHORTER COAT IS THAT WORN BY THE MEN)


After the dinner party, on the 18th of July, the two vessels started
for the north, being joined as soon as they stood from the
anchorage by Robert Shedden in his yacht the Nancy Dawson, who
at his own initiative had come up from Hong Kong to join in the
search. From Wainwright Inlet Kellett sent off the boats under
Lieutenant Pullen, two of which made the journey along the
northern coast and up the Mackenzie, their crews thence making
their way home eastwards to York Factory.
When Kellett was about to commence his observations at the inlet
he drew a semicircle on the sand from water's edge to water's edge,
and placed the boats' noses between its points. The natives seemed
to understand the meaning of this line. Not one of them attempted
to overstep it, and they squatted down and remained perfectly quiet
and silent. When a stranger arrived they shouted to him, and he no
sooner comprehended the directions than he crept rather than
walked to the boundary, and squatted among the rest. Afterwards
they danced and sang and played football with the seamen—who
stood no chance with them at that game—and when they had gone
off, after all this good behaviour, it was discovered that they had
been picking the pockets of some of the party, one losing a
handkerchief, another a glove, and Commander Moore a box of
percussion caps.
The boat party had a similar experience, without the pocket-picking.
Reaching Point Barrow they landed to make observations and look
about for traces of the visit of the Blossom's boat, which they did not
find. Their interpreter did not understand the tribe, and recourse
was had to the universal language of signs. "We made a rude model
of a vessel," says Lieutenant Hooper, "and performed sundry antics
to signify what we were in search of, but could elicit no information,
and so set to work at obtaining observations. We concluded that
these people must have been entirely misunderstood. Far from
evidencing any disposition to assail or molest us, they were most
docile and well-behaved, agreeably disappointing us in their conduct.
When we arrived on the hillock, all, big and little, sat down around
us, and I amused myself by filling their pipes, becoming a great
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

textbookfull.com

You might also like