Download as pdf or txt
Download as pdf or txt
You are on page 1of 55

The Software Developer's Guide to

Linux: A practical, no-nonsense guide


to using the Linux command line and
utilities as a software developer David
Cohen
Visit to download the full and correct content document:
https://ebookmass.com/product/the-software-developers-guide-to-linux-a-practical-no-
nonsense-guide-to-using-the-linux-command-line-and-utilities-as-a-software-develope
r-david-cohen-2/
More products digital (pdf, epub, mobi) instant
download maybe you interests ...

The Software Developer's Guide to Linux: A practical,


no-nonsense guide to using the Linux command line and
utilities as a software developer David Cohen

https://ebookmass.com/product/the-software-developers-guide-to-
linux-a-practical-no-nonsense-guide-to-using-the-linux-command-
line-and-utilities-as-a-software-developer-david-cohen-2/

A Friendly Guide to Software Development: What You


Should Know Without Being a Developer Leticia Portella

https://ebookmass.com/product/a-friendly-guide-to-software-
development-what-you-should-know-without-being-a-developer-
leticia-portella/

A Friendly Guide to Software Development: What You


Should Know Without Being a Developer 1st Edition
Leticia Portella

https://ebookmass.com/product/a-friendly-guide-to-software-
development-what-you-should-know-without-being-a-developer-1st-
edition-leticia-portella/

Linux+ and LPIC-1 Guide to Linux Certification, 5th


Edition Jason W. Eckert

https://ebookmass.com/product/linux-and-lpic-1-guide-to-linux-
certification-5th-edition-jason-w-eckert/
Linux+ and LPIC-1 Guide to Linux Certification, 5th
Edition Jason W. Eckert

https://ebookmass.com/product/linux-and-lpic-1-guide-to-linux-
certification-5th-edition-jason-w-eckert-2/

Introduction to Software Testing: A Practical Guide to


Testing, Design, Automation, and Execution 1st Edition
Panagiotis Leloudas

https://ebookmass.com/product/introduction-to-software-testing-a-
practical-guide-to-testing-design-automation-and-execution-1st-
edition-panagiotis-leloudas/

50 JavaScript Concepts Every Developer Should Know: The


Perfect Guide Every JavaScript Developer Needs to Get
Started (50 Concepts Every Developer Should Know Book
1) Abella
https://ebookmass.com/product/50-javascript-concepts-every-
developer-should-know-the-perfect-guide-every-javascript-
developer-needs-to-get-started-50-concepts-every-developer-
should-know-book-1-abella/

CompTIA A+ guide to software : managing, maintaining,


and troubleshooting Ninth Edition. Edition Andrews

https://ebookmass.com/product/comptia-a-guide-to-software-
managing-maintaining-and-troubleshooting-ninth-edition-edition-
andrews/

The Enterprise Linux Administrator: Journey to a New


Linux Career 1st Edition Kenneth Hitchcock

https://ebookmass.com/product/the-enterprise-linux-administrator-
journey-to-a-new-linux-career-1st-edition-kenneth-hitchcock/
The Software Developer’s
Guide to Linux

A practical, no-nonsense guide to using the Linux command line and


utilities as a software developer

David Cohen
Christian Sturm

BIRMINGHAM—MUMBAI
The Software Developer’s Guide to Linux
Copyright © 2024 Packt Publishing

All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in
any form or by any means, without the prior written permission of the publisher, except in the case of brief
quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information
presented. However, the information contained in this book is sold without warranty, either express or
implied. Neither the authors, nor Packt Publishing or its dealers and distributors, will be held liable for any
damages caused or alleged to have been caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products
mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee
the accuracy of this information.

Senior Publishing Product Manager: Aaron Tanna


Acquisition Editor – Peer Reviews: Gaurav Gavas
Project Editor: Parvathy Nair
Content Development Editor: Matthew Davies
Copy Editor: Safis Editing
Technical Editor: Karan Sonawane
Proofreader: Safis Editing
Indexer: Tejal Soni
Presentation Designer: Ganesh Bhadwalkar
Developer Relations Marketing Executive: Meghal Patel

First published: January 2024


Production reference: 1230124

Published by Packt Publishing Ltd.


Grosvenor House
11 St Paul’s Square
Birmingham
B3 1RB, UK.

ISBN 978-1-80461-692-5

www.packt.com
Contributors

About the authors


David Cohen has, for the past 15 years, worked as a Linux system administrator, software
engineer, infrastructure engineer, platform engineer, site reliability engineer, security engineer,
web developer, and a few other things besides. In his free time, he runs the tutorialinux YouTube
channel where he’s taught hundreds of thousands of people the basics of Linux, programming,
and DevOps. David has been at Hashicorp since 2019—first as an SRE, then as a reference architect,
and now as a software engineer.
Thank you, Aleyna, for your unwavering support over the past few years as I’ve been developing and writing
this book. Without you, this would just be another of my promising-but-unfinished projects languishing in
some forgotten “Archive” directory. Thanks to Christian, who has stuck with me for over a decade as a friend
and a partner on practically every wild tech project idea I’ve come up with since we met. Finally, a big “thank
you” is also due to my friends and colleagues at Hashicorp and everywhere else I’ve been over the past 15 years,
who have made me a better engineer and encouraged projects like this.

Christian Sturm is a consultant on software and systems architecture, having worked in var-
ious technical positions for well over a decade. He has worked as an application developer for
the frontend and backend at companies large and small, such as zoomsquare and Plutonium
Labs. On top of that, he is also an active contributor to various open source projects and has a
deep understanding of fields including operating systems, networking protocols, security, and
database management systems.
About the reviewers
Mario Splivalo works as a consultant dealing with databases extended into modern cloud-
based architectures. He also helps companies design their infrastructure using IaaC tools such as
Terraform and AWS Cloudformation. For five years, Mario worked with Canonical as an OpenStack
engineer.

Mario’s fascination with computers started back when Commodore 64 dominated the user space.
He took his first steps using BASIC on his dad’s C64, quickly shifting to Assembler. He gradually
moved to PCs, finding a great love for programming, systems design, and database administra-
tion. He switched to Linux (Knoppix, then Ubuntu, and never looked back) in the early 2000s,
continuing as a database administrator, programmer, and system administrator.

Nathan Chancellor is an independent contractor working on the Linux kernel, based in Ar-
izona, US. As a developer, his focus is on improving the compatibility between the Linux kernel
and the LLVM toolchain. He has used Linux since 2016 and it has been his primary development
operating system since 2018. His distributions of choice are Arch Linux and Fedora.
Learn more on Discord
To join the Discord community for this book – where you can share feedback, ask questions to
the author, and learn about new releases – follow the QR code below:

https://packt.link/SecNet
Table of Contents

Preface  xxiii

Chapter 1: How the Command Line Works  1

In the beginning…was the REPL ����������������������������������������������������������������������������������������� 1


Command-line syntax (read) ���������������������������������������������������������������������������������������������� 3
Command line vs. shell ������������������������������������������������������������������������������������������������������� 4
How does the shell know what to run? (evaluate) • 5
A quick definition of POSIX • 6
Basic command-line skills �������������������������������������������������������������������������������������������������� 7
Unix filesystem basics • 7
Absolute vs. relative file paths • 8
Absolute vs. relative pathname review • 10
Opening a terminal • 10
Looking around – command-line navigation • 10
pwd - print working directory • 10
ls - list • 11
Moving around • 12
cd – change directory • 12
find – find files • 13
Reading files • 13
less – page through a file • 14
Making changes • 14
viii Table of Contents

touch – create an empty file, or update modification time for an existing one • 14
mkdir – create a directory • 14
rmdir – remove empty directories • 15
rm – remove files and directories • 15
mv – move or rename files and directories • 16
Getting help ����������������������������������������������������������������������������������������������������������������������� 17
Shell autocompletion �������������������������������������������������������������������������������������������������������� 18
Conclusion ������������������������������������������������������������������������������������������������������������������������ 20

Chapter 2: Working with Processes  21

Process basics ������������������������������������������������������������������������������������������������������������������� 22


What is a Linux process made of? • 23
Process ID (PID) • 24
Effective User ID (EUID) and Effective Group ID (EGID) • 25
Environment variables • 25
Working directory • 25
Practical commands for working with Linux processes ���������������������������������������������������� 26
Advanced process concepts and tools �������������������������������������������������������������������������������� 28
Signals • 28
Practical uses of signals • 29
Trapping • 29
The kill command • 29
lsof – show file handles that a process has open • 31
Inheritance • 33
Review – example troubleshooting session ����������������������������������������������������������������������� 33
Conclusion ������������������������������������������������������������������������������������������������������������������������ 35

Chapter 3: Service Management with systemd  37

The basics ������������������������������������������������������������������������������������������������������������������������� 38


init • 39
Processes and services ������������������������������������������������������������������������������������������������������� 39
Table of Contents ix

systemctl commands �������������������������������������������������������������������������������������������������������� 40


Checking the status of a service • 40
Starting a service • 41
Stopping a service • 41
Restarting a service • 41
Reloading a service • 42
Enable and disable • 42
A note on Docker ��������������������������������������������������������������������������������������������������������������� 43
Conclusion ������������������������������������������������������������������������������������������������������������������������ 43

Chapter 4: Using Shell History  45

Shell history ���������������������������������������������������������������������������������������������������������������������� 45


Shell configuration files • 46
History files • 46
Searching through shell history • 47
Exceptions • 47
Executing previous commands with ! ������������������������������������������������������������������������������� 48
Re-running a command with the same arguments • 48
Prepending a command to something in your history • 48
Jumping to the beginning or end of the current line ��������������������������������������������������������� 49
Conclusion ������������������������������������������������������������������������������������������������������������������������ 49

Chapter 5: Introducing Files  51

Files on Linux: the absolute basics ������������������������������������������������������������������������������������ 52


Plaintext files • 52
What is a binary file? • 52
Line endings • 53
The filesystem tree ������������������������������������������������������������������������������������������������������������ 53
Basic filesystem operations ����������������������������������������������������������������������������������������������� 54
ls • 54
pwd • 55
x Table of Contents

cd • 55
touch • 56
less • 57
tail • 57
mv • 57
Moving • 57
Renaming • 58
cp • 58
mkdir • 58
rm • 58
Editing files ����������������������������������������������������������������������������������������������������������������������� 59
File types ��������������������������������������������������������������������������������������������������������������������������� 60
Symbolic links • 61
Hard links • 62
The file command • 62
Advanced file operations ��������������������������������������������������������������������������������������������������� 63
Searching file content with grep • 63
Finding files with find • 64
Copying files between local and remote hosts with rsync • 65
Combining find, grep, and rsync • 66
Advanced filesystem knowledge for the real world ����������������������������������������������������������� 67
FUSE: Even more fun with Unix filesystems • 68
Conclusion ������������������������������������������������������������������������������������������������������������������������ 69

Chapter 6: Editing Files on the Command Line  71

Nano ��������������������������������������������������������������������������������������������������������������������������������� 72
Installing nano • 72
Nano cheat sheet • 72
File handling • 73
Editing • 73
Search and replace • 73
Table of Contents xi

Vi(m) ��������������������������������������������������������������������������������������������������������������������������������� 73
Vi/vim commands • 74
Modes • 74
Command mode • 74
Normal mode • 75
Tips for learning vi(m) • 76
Use vimtutor • 76
Think in terms of mnemonics • 76
Avoid using arrow keys • 76
Avoid using the mouse • 77
Don’t use gvim • 77
Avoid starting with extensive configuration or plugins • 77
Vim bindings in other software • 79
Editing a file you don’t have permissions for �������������������������������������������������������������������� 79
Setting your preferred editor �������������������������������������������������������������������������������������������� 79
Conclusion ����������������������������������������������������������������������������������������������������������������������� 80

Chapter 7: Users and Groups  81

What is a user? ������������������������������������������������������������������������������������������������������������������ 81


Root versus everybody else ����������������������������������������������������������������������������������������������� 82
sudo ���������������������������������������������������������������������������������������������������������������������������������� 82
What is a group? ���������������������������������������������������������������������������������������������������������������� 84
Mini project: user and group management ����������������������������������������������������������������������� 84
Creating a user • 85
Create a group • 86
Modifying a Linux user • 86
Adding a Linux user to a group • 87
Removing a user from a group • 87
Removing a Linux user • 87
Remove a Linux group • 87
Advanced: what is a user, really? �������������������������������������������������������������������������������������� 88
User metadata / attributes • 88
xii Table of Contents

A note on scriptability ������������������������������������������������������������������������������������������������������� 90


Conclusion ������������������������������������������������������������������������������������������������������������������������ 90

Chapter 8: Ownership and Permissions  93

Deciphering a long listing ������������������������������������������������������������������������������������������������� 93


File attributes ������������������������������������������������������������������������������������������������������������������� 94
File type • 94
Permissions • 95
Number of hardlinks • 95
User ownership • 95
Group ownership • 95
File size • 96
Modification time • 96
Filename • 96
Ownership ������������������������������������������������������������������������������������������������������������������������ 96
Permissions ���������������������������������������������������������������������������������������������������������������������� 97
Numeric/octal • 98
Common permissions • 99
Changing ownership (chown) and permissions (chmod) ������������������������������������������������� 99
Chown • 99
Change owner • 99
Change owner and group • 100
Recursively change owner and group • 100
Chmod • 100
Using a reference • 101
Conclusion • 101

Chapter 9: Managing Installed Software  103

Working with software packages ������������������������������������������������������������������������������������ 104


Update your local cache of repository state • 105
Search for a package • 105
Table of Contents xiii

Install a package • 106


Upgrade all packages that have available updates • 106
Remove a package (and any dependencies, provided other packages don’t need them) • 106
Query installed packages • 107
Caution required – curl | bash ������������������������������������������������������������������������������������������ 107
Compiling third-party software from source ������������������������������������������������������������������ 108
Example: compiling and installing htop • 110
Install prerequisites • 110
Download, verify, and unarchive the source code • 110
Configure and compile htop • 111
Conclusion ����������������������������������������������������������������������������������������������������������������������� 112

Chapter 10: Configuring Software  115

Configuration hierarchy ��������������������������������������������������������������������������������������������������� 116


Command-line arguments ����������������������������������������������������������������������������������������������� 118
Environment variables ����������������������������������������������������������������������������������������������������� 119
Configuration files ����������������������������������������������������������������������������������������������������������� 121
System-level configuration in /etc/ • 121
User-level configuration in ~/.config • 121
systemd units ������������������������������������������������������������������������������������������������������������������� 122
Create your own service • 122
Quick note: configuration in Docker �������������������������������������������������������������������������������� 124
Conclusion ����������������������������������������������������������������������������������������������������������������������� 125

Chapter 11: Pipes and Redirection  127

File descriptors ��������������������������������������������������������������������������������������������������������������� 128


What do these file descriptors reference? • 129
Input and output redirection (or, playing with file descriptors for fun and profit) ���������� 129
Input redirection: < • 129
Output redirection: > • 130
Use >> to append output without overwriting • 131
xiv Table of Contents

Error redirection with 2> • 132


Connecting commands together with pipes (|) ���������������������������������������������������������������� 133
Multi-pipe commands • 133
Reading (and building) complex multi-pipe commands • 134
The CLI tools you need to know ��������������������������������������������������������������������������������������� 134
cut • 134
sort • 135
uniq • 136
Counting • 136
wc • 137
head • 138
tail • 138
tee • 138
awk • 139
sed • 139
Practical pipe patterns ���������������������������������������������������������������������������������������������������� 140
“Top X”, with count • 140
curl | bash • 140
Security considerations for curl | sudo | bash • 141
Filtering and searching with grep • 142
grep and tail for log monitoring • 143
find and xargs for bulk file operations • 143
sort, uniq, and reverse numerical sort for data analysis • 144
awk and sort for reformatting data and field-based processing • 145
sed and tee for editing and backup • 145
ps, grep, awk, xargs, and kill for process management • 146
tar and gzip for backup and compression • 146
Advanced: inspecting file descriptors ������������������������������������������������������������������������������� 147
Conclusion ����������������������������������������������������������������������������������������������������������������������� 149
Table of Contents xv

Chapter 12: Automating Tasks with Shell Scripts  151

Why you need Bash scripting basics ��������������������������������������������������������������������������������� 152


Basics ������������������������������������������������������������������������������������������������������������������������������� 152
Variables • 152
Setting • 152
Getting • 153
Bash versus other shells ��������������������������������������������������������������������������������������������������� 153
Shebangs and executable text files, aka scripts ���������������������������������������������������������������� 154
Common Bash settings (options/arguments) • 154
/usr/bin/env • 155
Special characters and escaping • 156
Command substitution • 157
Testing ����������������������������������������������������������������������������������������������������������������������������� 157
Testing operators • 157
[[ file and string testing ]] • 158
Useful operators for string testing • 158
Useful operators for file testing • 158
(( arithmetic testing )) • 159
Conditionals: if/then/else ����������������������������������������������������������������������������������������������� 160
ifelse • 160
Loops ������������������������������������������������������������������������������������������������������������������������������ 160
C-style loops • 160
for…in • 161
While • 161
Variable exporting • 162
Functions ������������������������������������������������������������������������������������������������������������������������� 162
Prefer local variables • 163
xvi Table of Contents

Input and output redirection ������������������������������������������������������������������������������������������ 164


<: input redirection • 164
> and >>: output redirection • 164
Use 2>&1 to redirect STDERR and STDOUT • 164
Variable interpolation syntax – ${} ����������������������������������������������������������������������������������� 165
Limitations of shell scripts ����������������������������������������������������������������������������������������������� 165
Conclusion ���������������������������������������������������������������������������������������������������������������������� 166
Citations ������������������������������������������������������������������������������������������������������������������������� 166

Chapter 13: Secure Remote Access with SSH  167

Public key cryptography primer �������������������������������������������������������������������������������������� 168


Message encryption • 168
Message signing • 169
SSH keys ��������������������������������������������������������������������������������������������������������������������������� 169
Exceptions to these rules • 170
Logging in and authenticating • 171
Practical project: Set up a key-based login to a remote server ������������������������������������������ 171
Step 1: Open your terminal on the SSH client (not the server) • 171
Step 2: Generate the key pair • 172
Step 3: Copy the public key to your server • 172
Step 4: Test it out! • 172
Converting SSH2 keys to the OpenSSH format ����������������������������������������������������������������� 173
What we are trying to achieve • 173
How to convert the SSH2-formatted key to OpenSSH • 174
The other direction: Converting SSH2 keys to the OpenSSH format • 174
SSH-agent ������������������������������������������������������������������������������������������������������������������������ 175
Common SSH errors and the -v (verbose) argument �������������������������������������������������������� 176
File transfer ���������������������������������������������������������������������������������������������������������������������� 177
SFTP • 178
SCP • 178
Clever examples • 179
Table of Contents xvii

Without SFTP or SCP • 180


Directory upload and .tar.gz compression • 180
Tunnels ���������������������������������������������������������������������������������������������������������������������������� 181
Local forwarding • 181
Proxying • 181
The configuration file ������������������������������������������������������������������������������������������������������ 182
Conclusion ���������������������������������������������������������������������������������������������������������������������� 183

Chapter 14: Version Control with Git  185

Some background on Git ������������������������������������������������������������������������������������������������� 186


What is a distributed version control system? ����������������������������������������������������������������� 186
Git basics ������������������������������������������������������������������������������������������������������������������������� 187
First-time setup • 187
Initialize a new Git repository • 187
Make and see changes • 187
Stage and commit changes • 187
Optional: add a remote Git repository • 188
Pushing and pulling • 188
Cloning a repository • 188
Terms you might come across ����������������������������������������������������������������������������������������� 189
Repository • 189
Bare repository • 189
Branch • 189
Main/master branch • 190
HEAD • 190
Tag • 190
Shallow • 190
Merging • 190
Merge commit • 191
Merge conflict • 191
Stash • 191
xviii Table of Contents

Pull request • 191


Cherry-picking • 192
Bisecting • 192
Rebasing • 193
Best practices for commit messages �������������������������������������������������������������������������������� 196
Good commit messages • 196
GUIs ��������������������������������������������������������������������������������������������������������������������������������� 197
Useful shell aliases ����������������������������������������������������������������������������������������������������������� 197
Poor man’s GitHub ���������������������������������������������������������������������������������������������������������� 198
Considerations • 198
1. Connect to your server • 198
2. Install Git • 198
3. Initialize a repository • 199
4. Clone the repository • 199
5. Edit the project and push your changes • 200
Conclusion ��������������������������������������������������������������������������������������������������������������������� 200

Chapter 15: Containerizing Applications with Docker  203

How containers work as packages ���������������������������������������������������������������������������������� 204


Prerequisite: Docker install ��������������������������������������������������������������������������������������������� 205
Docker crash course �������������������������������������������������������������������������������������������������������� 205
Creating images with a Dockerfile ��������������������������������������������������������������������������������� 208
Container commands ������������������������������������������������������������������������������������������������������ 210
docker run • 210
docker image list • 211
docker ps • 211
docker exec • 212
docker stop • 212
Docker project: Python/Flask application container �������������������������������������������������������� 212
1. Set up the application • 213
2. Create the Docker image • 215
Table of Contents xix

3. Start a container from your image • 215


Containers vs. virtual machines ��������������������������������������������������������������������������������������� 216
A quick note on Docker image repositories ���������������������������������������������������������������������� 217
Painfully learned container lessons ��������������������������������������������������������������������������������� 217
Image size • 218
C standard library • 218
Production is not your laptop: outside dependencies • 218
Container theory: namespacing ��������������������������������������������������������������������������������������� 219
How do we do Ops with containers? ������������������������������������������������������������������������������� 220
Conclusion ���������������������������������������������������������������������������������������������������������������������� 220

Chapter 16: Monitoring Application Logs  223

Introduction to logging ��������������������������������������������������������������������������������������������������� 224


Logging on Linux can get... weird • 224
Sending log messages • 225
The systemd journal ������������������������������������������������������������������������������������������������������� 225
Example journalctl commands ��������������������������������������������������������������������������������������� 226
Following active logs for a unit • 226
Filtering by time • 226
Filtering for a specific log level • 227
Inspecting logs from a previous boot • 227
Kernel messages • 227
Logging in Docker containers ����������������������������������������������������������������������������������������� 228
Syslog basics ������������������������������������������������������������������������������������������������������������������� 228
Facilities • 229
Severity levels • 230
Configuration and implementations • 230
Tips for logging ��������������������������������������������������������������������������������������������������������������� 230
Keywords when using structured logging • 230
Severity • 231
xx Table of Contents

Centralized logging ���������������������������������������������������������������������������������������������������������� 231


Conclusion ���������������������������������������������������������������������������������������������������������������������� 233

Chapter 17: Load Balancing and HTTP  235

Basic terminology ����������������������������������������������������������������������������������������������������������� 236


Gateway • 236
Upstream • 237
Common misunderstandings about HTTP ���������������������������������������������������������������������� 237
HTTP statuses • 237
Don’t just check for 200 OK • 237
404 Not Found • 238
502 Bad Gateway • 238
503 Service Unavailable • 239
504 Gateway Timeout • 239
Introduction to curl: checking HTTP response status • 239
HTTP headers • 240
Case-insensitive headers • 240
Custom headers • 240
Viewing HTTP headers with curl • 241
HTTP versions • 241
HTTP/0.9 • 241
HTTP/1.0 and HTTP/1.1 • 242
HTTP/2 • 242
HTTP/3 and QUIC • 243
Load balancing • 244
Sticky sessions, cookies, and deterministic hashing • 245
Round-robin load balancing • 246
Other mechanisms • 246
High availability • 246
Troubleshooting redirects with curl • 247
Using curl as an API testing tool • 248
Table of Contents xxi

Accepting and displaying bad TLS certificates with curl • 249


CORS • 249
Conclusion ����������������������������������������������������������������������������������������������������������������������� 251

Other Books You May Enjoy  255

Index  259
Preface
Many software engineers are new to Unix-like systems, even though these systems are everywhere
in the software engineering world. Whether developers know it or not, they’re expected to work
with Unix-like systems running in their work environment (macOS), their software development
process (Docker containers), their build and automation tooling (CI and GitHub), their production
environments (Linux servers and containers), and more.

Being skilled with the Linux command line can help software developers go beyond what’s ex-
pected of them, allowing them to:

• Save time by knowing when to use built-in Unix tools, instead of writing thousand-line
scripts or helper programs
• Help debug complex production outages, often involving Linux servers and their interface
to the application
• Mentor junior engineers
• Have a more complete understanding of how the software they write fits into the larger
ecosystem and tech stack

We hope that the theory, examples, and projects included in this book can take your Linux de-
velopment skills to the next level.

Who this book is for


This book is for software developers who are new to Linux and the command line, or who are out
of practice and want to quickly dust off their skills. If you still feel a bit insecure about your abil-
ities when you’re staring at a Linux command-line prompt on a production server at 2:00 in the
morning, this book is for you. If you want to quickly fill a Linux skills gap to advance your career,
this book is for you. If you’re just curious, and you want to see what kind of efficiency gains you
can make in your day-to-day development setup and routines by adding some command-line
magic, this book will serve you as well.
xxiv Preface

What this book is not


One of the ways we have tried to fulfill our vision for this kind of uniquely useful book is by being
extremely careful about what’s included. We’ve tried to cut out everything that isn’t essential to
your life as a developer, or to a basic understanding of Linux and its core abstractions. In other
words, the reason this book is useful is because of all the things we left out.

This book is not a full Linux course. It’s not for people working as Linux system engineers or kernel
developers. Because of this, it’s not 750+ pages long, and you should be able to work through it
in a few days, perhaps during a quiet sprint at work.

What this book covers


Chapter 1, How the Command Line Works, explains how a command-line interface works, what
a shell is, and then immediately gives you some basic Linux skills. You’ll get a bit of theory and
then begin moving around on the command line, finding and working with files and learning
where to look for help when you get stuck. This chapter caters to new developers by teaching
the most important command-line skills. If you read nothing else, you’ll still be better off than
when you started.

Chapter 2, Working with Processes, will take you on a guided tour of Linux processes. You’ll then
dive into useful, practical command-line skills for working with processes. We’ll add detail to
a few aspects that are a common source of process-related problems that you’ll encounter as a
software developer, like permissions, and give you some heuristics for troubleshooting them.
You’ll also get a quick tour of some advanced topics that will come up again later in the book.

Chapter 3, Service Management with systemd, builds on the knowledge about processes learned in
the previous chapter by introducing an additional layer of abstraction, the systemd service. You’ll
learn about what an init system does for an operating system, and why you should care. Then,
we cover all the practical commands you’ll need for working with services on a Linux system.

Chapter 4, Using Shell History, is a short chapter covering some tricks that you can learn to improve
your speed and efficiency on the command line. These tricks revolve around using shortcuts and
leveraging shell history to avoid repeated keystrokes.

Chapter 5, Introducing Files, introduces files as the essential abstraction through which to under-
stand Linux. You’ll be introduced to the Filesystem Hierarchy Standard (FHS), which is like a
map that you can use to orient yourself on any Unix system. Then it’s time for practical commands
for working with files and directories in Linux, including some special filetypes you probably
haven’t heard of. You’ll also get a taste of searching for files and file content, which is one of the
most powerful bits of knowledge to have at your fingertips as a developer.
Preface xxv

Chapter 6, Editing Files on the Command Line, introduces two text editors – nano and vim. You will
learn the basics of using these text editors for command-line editing while also becoming aware
of common editing mistakes and how to avoid them.

Chapter 7, Users and Groups, will introduce you to how the concepts of users and groups form the
basis for the Unix security model, controlling access for resources like files and processes. We’ll
then teach you the practical commands you’ll need to create and modify users and groups.

Chapter 8, Ownership and Permissions, builds on the previous chapter’s explanation of users and
groups to show you how access control works for resources in Linux. This chapter teaches you
about ownership and permissions by walking you through file information from a long listing.
From there, we’ll look at the common file and directory permissions that you’ll encounter on
production Linux systems, before engaging with the Linux commands for modifying file own-
ership and permissions.

Chapter 9, Managing Installed Software, shows you how to install software on various Linux distri-
butions (and even macOS). First, we introduce package managers, which are the preferred way of
getting software onto a machine: you’ll learn the important theory and practical commands for the
package management operations you’ll need as a software developer. Then we’ll introduce a few
other methods, like downloading install scripts and the time-honored, artisanal Unix tradition
of compiling your own software locally, from source (it’s not as scary as it sounds!).

Chapter 10, Configuring Software, piggybacks off the previous chapter’s focus on installing soft-
ware by helping you with configuring software on a Linux system. You will learn about the places
that most software will look for configuration (“the configuration hierarchy”). Not only will
this knowledge come in handy during late-night troubleshooting sessions, but it can actually
help you to write better software. We’ll cover command-line arguments, environment variables,
configuration files, and how all of this works on non-standard Linux environments like Docker
containers. There’s even a little bonus project: you’ll see how to take a custom program and turn
it into its own systemd service.

Chapter 11, Pipes and Redirection, will give you an introduction to what is possibly the “killer feature”
of Unix: the ability to connect existing programs into a custom solution using pipes. We’ll move
through the prerequisite theory and practical skills you need to understand: file descriptors and
input/output redirection. Then you’ll jump into creating complex commands using pipes. You’ll be
introduced to some essential CLI tools and practical pipe patterns, which you’ll still find yourself
using long after you finish this book.
xxvi Preface

Chapter 12, Automating Tasks with Shell Scripts, serves as a Bash scripting crash course, teaching you
how to go from typing individual commands in an interactive shell to writing scripts. We assume
you’re already a software developer, so this will be a quick introduction that shows you the core
language features and doesn’t spend a lot of time re-explaining the basics of programming. You’ll
learn about Bash syntax, best practices for script writing, and some important pitfalls to avoid.

Chapter 13, Secure Remote Access with SSH, explores the Secure Shell Protocol and the related com-
mand-line tools available to you. You’ll learn the basics of public-key cryptography (PKI), which
is always useful for a developer to know, before diving into creating SSH keys and securely logging
into remote systems over the network. You’ll build on this knowledge and get some experience
copying files over the network, using SSH to create ad-hoc proxies or VPNs, and see examples of
various other tasks that involve moving data over an encrypted SSH tunnel.

Chapter 14, Version Control with Git, shows you how to use a tool you probably already know well
– git – from the command line, instead of through your IDE or a graphical client. We quickly go
through the basic theory behind git and then jump into the commands you’ll need to use in a
command-line environment. We’ll cover two powerful features that it pays to understand – bi-
secting and rebasing – and then give you our take on best practices and useful shell aliases. Finally,
the Poor man’s GitHub section presents a small but legitimately useful project that you can do to
practice and integrate the Linux skills you’ve learned up to this point.

Chapter 15, Containerizing Applications with Docker, gives you the basic theory and practical skills
that will make it easy to work with Docker as a developer. We’ll explore the problems that Docker
solves, explain the most important Docker concepts, and take you through the core workflow
and commands you’ll use. You’ll also see how to build your own images by containerizing a
real application. And because we’re approaching this from a software development and Linux
perspective, you’ll also develop a good intuition for how containerization works under the hood,
and how it’s different from virtual machines.

Chapter 16, Monitoring Application Logs, gives an overview of logging on Unix and Linux. We’ll
show you how (and where) logs are collected on most modern Linux systems using systemd, and
how more traditional approaches work (you’ll come across both in the real world). You’ll build
practical command-line skills finding and viewing logs and learn a bit about how logging is being
done in larger infrastructures.
Preface xxvii

Chapter 17, Load Balancing and HTTP, covers the basics of HTTP for developers, with a special
focus on the complexities that you’ll come across when working with HTTP services in larger
infrastructures. We’ll correct some common misunderstandings about HTTP statuses, HTTP
headers, and HTTP versions and how applications should handle them. We’ll also introduce
how load balancers and proxies work in the real world, and how they make the experience of
troubleshooting a live application quite different from troubleshooting a development version
on your laptop. Many of the Linux skills that you will have learned up to this point will come in
handy here, and we’ll introduce a new tool – curl – to help you troubleshoot a wide variety of
HTTP-related issues.

To get the most out of this book


If you can get yourself to a Linux shell prompt – by installing Ubuntu in a virtual machine or
running it as a Docker container, for example – you can follow along with everything in this book.

You can get away with even less – on Windows, there’s WSL, and macOS is a bona-fide Unix
operating system, so almost all of the practical commands you learn in this book (except those
called out as Linux-only) will work out of the box. That said, for the best experience, follow along
on a Linux operating system.

The skills required to get the most out of this book are only the basic computer skills that you
already have as a software developer – editing text, working with files and folders, having some
notion of what “operating systems” are, installing software, and using a development environ-
ment. Everything beyond that, we’ll teach you.

Download the color images


We also provide a PDF file that has color images of the screenshots/diagrams used in this book.
You can download it here: https://packt.link/gbp/9781804616925.

Conventions used
There are a number of text conventions used throughout this book.

CodeInText: Indicates code words in text, database table names, folder names, filenames, file
extensions, pathnames, dummy URLs, user input, and Twitter handles. For example: “The -f
flag stands for ‘follow,’ and the -u flag stands for ‘unit.’”
xxviii Preface

A block of command line is set as follows:


/home/steve/Desktop# ls
anotherfile documents somefile.txt stuff
/home/steve/Desktop# cd documents/
/home/steve/Desktop/documents# ls
contract.txt

Bold: Indicates a new term, an important word, or words that you see on the screen For instance,
words in menus or dialog boxes appear in the text like this. For example: “When a file is set to be
executable, Unix will do its best to execute it, either succeeding in the case of ELF (Executable
and Linkable Format, probably the most widely used executable format today) or failing.”

Warnings or important notes appear like this.

Tips and tricks appear like this.

Get in touch
Feedback from our readers is always welcome.
General feedback: Email feedback@packtpub.com, and mention the book’s title in the subject of
your message. If you have questions about any aspect of this book, please email us at questions@
packtpub.com.

Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do
happen. If you have found a mistake in this book we would be grateful if you would report this
to us. Please visit, http://www.packtpub.com/submit-errata, selecting your book, clicking on
the Errata Submission Form link, and entering the details.

Piracy: If you come across any illegal copies of our works in any form on the Internet, we would
be grateful if you would provide us with the location address or website name. Please contact us
at copyright@packtpub.com with a link to the material.
Preface xxix

If you are interested in becoming an author: If there is a topic that you have expertise in and you
are interested in either writing or contributing to a book, please visit http://authors.packtpub.
com.

Share your thoughts


Once you’ve read The Software Developer’s Guide to Linux, we’d love to hear your thoughts! Please
click here to go straight to the Amazon review page for this book and share your feedback.

Your review is important to us and the tech community and will help us make sure we’re deliv-
ering excellent quality content.
Another random document with
no related content on Scribd:
Men’s political movements toward freedom have nearly always
been accompanied by “confused noise and garments rolled in
blood.” No great emancipating evolution for men has taken place
without violence and bloodshed. One of our most learned historians,
Lord Acton, wrote: “It seems to be a law of political evolution that no
great advance of human freedom can be gained except after the
display of some kind of violence.” Yet notwithstanding all precedents
to the contrary, but just because men are men and women are
women, the women’s movement toward freedom did progress and
progress marvelously for the first half of the nineteenth century till
about six years ago without the use of any kind of violence. We shot
no one, we exploded no bombs, we destroyed nothing; but we have
been building up and creating a new social order in which the
women of to-day occupy a wholly different and better place from that
occupied by the women of preceding ages. The universities have
been opened; girls’ schools have been made over again, and made
different; the medical and, in many countries, the legal, professions
have been opened; municipal and all other local franchises in Great
Britain and her colonies have been won; women have been made
eligible for election on all local governing bodies; the civil service has
been opened; the barbarity of medieval laws founded on the
absolute subjection of women in marriage has been modified; full
parliamentary suffrage has been won for women in New Zealand
and Australia, in Finland and Norway, in Wyoming, Colorado, Utah,
Idaho, Washington, and California, and women’s suffrage
amendments have been recommended to the electorate by the
representative governing bodies of six other of the United States. All
these actual victories and indications of further victories in the near
future have been won (Lord Acton notwithstanding) without violence
of any kind. The American humorist Mark Twain, with his keen
practical insight into the essence of things, remarked this strange
feature of the women’s movement. He wrote in “More Tramps
Abroad,” p. 208:

For forty years they have swept an imposingly large number of unfair
laws from the statute books of America. In this brief time these serfs have
set themselves free—essentially. Men could not have done as much for
themselves in that time without bloodshed, at least they never have, and
that is an argument that they didn’t know how.

All these great and indeed immense victories for the cause of
human freedom have been accomplished by moral force and not by
physical force. Physical force as a means of promoting women’s
freedom was never even heard of till about six years ago, and for the
first two and a half years of their activity the so-called militant
suffragists did not use physical violence toward their adversaries;
they suffered violence far more than they inflicted it.
At the outset, so long as they confined themselves merely to
sensational and eccentric means of propaganda, they could hardly
be looked upon as a physical force party; they undoubtedly did
service to our common cause by making the claims of women more
widely known; there is probably hardly a village, hardly a family in
which the claims of women to share in the representative system of
the country has not been eagerly discussed. This to a very large
extent we owe to the activities of the “militants.” But when they
departed from the attitude they first adopted, of suffering violence but
using none, in my judgment they put themselves in the wrong
morally; and if judged from the point of view of practical success
have put back the cause rather than promoted it. For twenty-six
years from 1886 to 1912 women’s suffrage was never once defeated
in the House of Commons. The Conciliation Bill, which had been
carried in second reading in 1911 by a majority 316 to 143 after a
truce from militancy of nearly eighteen months, was defeated in 1912
by a narrow majority. This was very largely due to the intense
indignation and resentment caused by the window-smashing
outrages which had taken place a few weeks earlier.
The carrying of a women’s suffrage amendment to the
government Reform Bill is the next stage either of victory or defeat
which awaits us. If militancy is renewed, defeat is almost certain. The
average man is not convinced of the value of conferring full
citizenship on women by hearing of tradesmen’s windows being
broken, or of attempts to set houses and theaters on fire. The
militants often claim that a display of physical violence is the only
way to success. This, I maintain, is a wholly mistaken reading of the
facts. Our victories have been won through convincing large masses
of quiet, sensible, average men and women that the citizenship of
women would be good for women themselves and for the State as a
whole. We can point to the activities of such women as Julia Ward
Howe and Jane Addams in the United States, of Florence
Nightingale and Josephine Butler in Great Britain, and can more and
more convince our countrymen of the futility and absurdity and the
loss to the community of excluding such women, and women at
large, from the rights of citizenship. I regard the militants as
misguided enthusiasts, and believe that at this moment they are the
most dangerous obstacles in the way of the immediate success of
our cause in England. But when I compare the degree of violence
they have used with the excesses of, say, the French Revolution or
the destructive fury which swept over our own and other countries, in
connection with the Reformation, or with the awful violence which
has occasionally been associated with the Labor movement both in
this country and in the United States, we may feel that there is no
cause for panic and still less for despair. The political emancipation
of women has made immense strides toward complete realization in
the English-speaking countries on both sides of the Atlantic. Every
victory scored by either of us helps the other. The latest honors are
with America. We do not grudge them; but hope soon to vie with
them.
A WAY OUT OF THE CANAL BLUNDER: REPEAL
THE EXEMPTION

A NY one who knows how little consideration is given to the


preparation of political platforms can readily understand how
both the Democratic and the Progressive parties were
“committed” to the blunder of advocating the exemption of our
coastwise shipping from the tolls to be charged for the use of the
Panama Canal. It is this sort of inside arrangement of party policies
—which usually, in the last hours of fatigue, restlessness, and
excitement, there is never time to discuss on their merits—that has
cast discredit on platforms and has justified many a candidate in
disregarding or modifying a given “plank.” The overwhelming
judgment of our people, as reflected in the press, that nothing is so
important to us as a strict observance of our plighted faith,—just as
nothing is so important to a merchant as his credit and reputation for
honorable dealing,—shows how easy it is for half a dozen men in a
hotel parlor, at the suggestion of some “good fellow,” to lead a
convention to the indorsement of a disastrous policy.
To claim that we have not broken our pledge that there shall be
no discrimination in the tolls and conditions when we thus favor our
own coastwise trade, as against that of Canada, Mexico, and
Colombia,—each with an Atlantic and a Pacific coast,—simply does
not rise to the dignity of a quibble. Already by misrepresentation of
the sense of fair-dealing which pervades American commercial life,
incalculable injury has been done to our standing abroad—an injury
which cannot be measured in money. After all our honorable
diplomacy—the return of the Boxer indemnity, the open door policy
in the Far East, and the strict observance of our promise to withdraw
from Cuba, which foreign sneerers at America said we never would
observe, “and never meant to observe”—it is shameful to have to
drop to a lower plane of national conduct.
As if our cup of humiliation were not already full, it is argued that
we are at liberty to refuse to submit the question of the breach of the
Panama Treaty to the Hague Tribunal, if Great Britain should make
the appeal. “Nicht zwei dumme streiche für eins” (Not two stupid
strokes for one), says Lessing’s character in “Minna von Barnhelm.”
Unless we desire to become the welsher of the nations, it is time that
the good faith of the people should find an adequate expression in
the good faith of the Government. All the money saved (to whom?) in
tolls in a hundred years by the exemption could not compensate for
the loss in money—not to reckon honor—which will result from the
loss of credit and of great commercial opportunities all over the
world. A strange way, indeed, to promote American commerce!
But there remains for us another chance—or will, if Great Britain
shall a little longer pursue her friendly and forbearing course of
waiting for our public opinion to assert itself. The coastwise
exemption should be repealed. And, our obligations aside, why
should we enter upon a policy of subsidizing our ships just at the
time when apparently we are giving up the policy of subsidizing our
manufactures? Are we never to get away from the inequality of
privilege, that has already corrupted the sources of government by
the “vicious circle,” creating and feeding by legislation agencies
whose natural interest it thus becomes to destroy the principle of
equality? Why subsidize ships any more than subsidize railways, or
newspapers, or authorship? But if we must subsidize our ships, let it
be done outright, in bills for that purpose, and not through the
violation of the plain words of a solemn treaty.
Not only should the exemption be repealed, but, if we are to
recover the ground that has been lost, it should be done in the first
week of the December session of Congress. We feel sure that
President Taft, whose misgivings tinctured his message of assent,
now that the Canal bill has provided for a modus operandi, would not
interpose his veto to the sober second thought of Congress. If the
repeal is not accomplished, and if we refuse the appeal to The
Hague, the great cause of Arbitration—the substitute for war—will be
set back for unreckonable years. And it is the championship of
Arbitration, together with his far-sighted and consistent defense and
extension of the Merit System, which will give the President his
highest claim to the respect of posterity. The object of the latter is to
keep politicians from gambling with the resources of office; the object
of the former is to prevent governments from gambling with the lives
of men.
Should the repeal not be promptly made, it will become the duty
of the people to organize to bring it about. We much mistake the
temper of the country if within another six months its servants do not
remove this blot in the national escutcheon.
WANTED: STRAIGHT THINKING ABOUT MILITANT
SUFFRAGISTS

APROPOS OF THE RENEWAL OF VIOLENCE IN


ENGLAND

O NE of the startling signs of the times is the recrudescence of


violence among the militant suffragists in England. The physical
attacks by women upon members of the government, including
the hurling of a hatchet at the Prime Minister’s party; the attempt to
set fire to a theater in which he was about to make an address, and
other outrages, are in themselves a sufficiently deplorable symptom
of lawless impulses, with which the government, as it was obliged,
has dealt promptly and vigorously. As we have recognized in
previous articles, this course of action has been disavowed in
England by other prominent bodies of suffragists, who deserve honor
for their refusal to be deflected from their “appeal to reason” to a
policy which can only end in disaster. In this number of THE CENTURY
we give place to an article by Mrs. Fawcett, President of the National
Union of Women’s Suffrage Societies, of Great Britain, written at our
request for a disavowal of this policy. If, besides the editorials in the
New York “Evening Post,” there has been any similar official
disavowal in America, it has escaped the attention of one careful
reader of the daily news. Already many men in this country must be
asking themselves whether it is wise to add to the electorate a body
of voters who do not see the perilous influence of tolerating such
actions—the influence not only upon women, but upon other
impressionable classes having a real or fancied grievance.
And now comes another test of the wisdom and patriotism of
these ladies. Before these lines shall be published, Mr. and Mrs.
Pethick Lawrence, two convicted lawbreakers of England, are to be
honored by a reception by the National Woman Suffrage Association
in New York, as Mrs. Pankhurst was received at Carnegie Hall after
a similar conviction. We cannot conceal our sympathy with any
person willing to suffer for opinion’s sake, but in these instances the
punishment was inflicted not for opinion, but for deliberate violation
of the elementary principles of civilized government—by the
destruction of property (usually of unoffending persons) and the
creation of public disorder. Of what use is it for conservative
agencies to address themselves to the discouragement of lynching
in the South, or in Pennsylvania, or of hired assassination in New
York City, or the lawlessness of capital or of labor, or the lawlessness
of brutal students, fashionable smugglers, bribed officials, or “fixed”
juries, when the sentiment of so large and estimable a part of the
community as the advocates of woman suffrage—teachers of the
young—fail to see their responsibility toward their followers and the
public? The defense that “no class has ever obtained its rights
except by violence” is both false and insidious, and sets an example
which will rise to plague the women themselves if they ever obtain a
measure of responsible power. Deeper even than this vicious idea is
the world-old delusion—which has its strongest exponent in politics
—that the end justifies the means. The drift toward the employment
of this standard is a hard blow to those who believe that women are
to show us a more excellent way in government.
Admitting that this policy of terrorizing one’s opponents is
valuable as advertising a movement, it seems never to have
occurred to the advocates of woman suffrage that as effective a
presentation of their cause could have been obtained without
violence. Ruskin said that war would cease in Europe if on the
declaration of hostilities Englishwomen would put on mourning.
Ingenuity certainly could devise some form of réclame more worthy
than the precipitation of delicately minded young women into the
program of a New York vaudeville theater. Something must be
allowed to the instinctive protest of human nature that everything
shall not be thrown into the melting-pot of agitation.
THE NEW WAY OF FINANCING A CAMPAIGN

A NOTE OF POLITICAL HEALTH AND PROGRESS

W E called slaveholding and Mormon polygamy “twin relics of


barbarism,” persisting in our modern civilization, and we put an
end to them long ago. We have now made an end of those
twin evils of our politics, the spoils system and secret campaign
funds. Ten years of agitation put the merit system into our laws, the
movement for publicity of campaign contributions, actively urged on
after 1904, became effective in less than six years. The Federal act
bears date of June 25, 1910. The spoils system and the secret
campaign fund have the likeness of twins. Both are a fraud upon the
people, both are illegitimate devices for perpetuating party power,
both are indefensible save by frankly and cynically immoral
arguments.
Perhaps the greater evil of the two, as a betrayal of the interests
of the people, is the acceptance by campaign committees of large
gifts of money from persons or corporations who expect, and who
have usually received, much more than the worth of their money in
legislative favors or valuable privilege. There have been many
indiscreet revelations of the theory and practical working of the
system. Indignantly protesting that the highly protected
manufacturing interests had been too niggardly in their giving, one
politician gave instructions to “fry the fat” out of them; and it is
notorious that in the field of tariff legislation the covenant between
the party in power and the corporations that gave bountifully to keep
it in power was faithfully kept. The hand that gave the fund guided
the pen that wrote the schedules. It is equally notorious that with
these great sums the suffrage was corrupted. In one of the States
where directions were given to marshal the “floaters” in “blocks of
five,” a distinguished beneficiary of that process humorously
admitted the efficiency of “soap” in achieving the victory. It was bad,
wholly bad; in a republic no political evil could be much worse.
The completeness of the reform is astonishing. The statute
enacted two years ago and amended last year commands campaign
committees to keep accurate accounts of receipts and expenditures,
and sworn detailed statement of contributions received, with
contributors’ names and the objects for which the money was spent,
must be filed with the Clerk of the House of Representatives fifteen
days before the day of election and every sixth day thereafter; thirty
days after election a final statement must be so filed. The statements
are open for inspection and publication.
This law of publicity has been complied with in this campaign with
such alacrity that two of the party committees “rushed into print” with
their statements of contributions more than a month in advance of
the date fixed by the statute. The Democratic committee gave out
the names and the figures on September 9, and on September 10
the statement of the Progressive party was given out.
It was then that the public suddenly became aware that this
Presidential campaign is unlike any other in our recent history. The
first striking fact observed was that the total of the contributions was
pitifully meager compared with the royal profusion with which,
according to the prevailing belief, former campaign committees have
been put in funds. The Wilson and Marshall Committee
acknowledged the receipt of $175,000 up to the date of publication,
and there were only three gifts as large as ten thousand dollars; the
Roosevelt and Johnson Committee had received $55,199, and the
largest contributions were two of $15,000 each. Comparison was at
once made with the Republican campaign fund of 1904, amounting
to $1,900,000 as stated in testimony and with old-time individual
contributions of $50,000 and $100,000. The total of the Republican
fund in 1896 is not accurately known, but it was certainly much larger
than in 1904.
The second point of unlikeness of this campaign to all others
within any man’s memory is the fact that the fortunes of all three
candidates are committed to the management of men who are
amateurs in “big politics.” The “Zach” Chandlers, the Mark Hannas,
the Arthur Pue Gormans, where are they? If these men have
successors in our day, they are watching and waiting, it may be;
certainly they are not in the strife, they are not at the heads of the
committees, they are not the chief men in the work.
It means that our politics, our political campaign methods, have in
good faith been changed and reformed. As a part of what in the
broad sense, not in any party sense, we may call the progressive
movement, this change is of impressive significance. The machines
and the bosses may devise ways to retain much of their old power
under the conditions of what is called “direct government” of the
people in the States, but now that their dominance is destroyed in
respect to the great quadrennial contest of the parties, it is not easy
to see how they can regain control. They carried on the war of
politics with money; they bartered, when they could, government
policies for cash. We have put an end to all that. The qualities of the
candidates, the merits of the argument, the decision of the people for
or against promised measures and policies, are now to be
determining. That is as it should be, it is the ideal way, in a
government by the people. For a government by the “interests” and
the politicians the old way was ideal.
In very truth the publicity of campaign contributions is a reform of
far-reaching vitality and importance, and it is immensely gratifying
that it has been ungrudgingly accepted by those upon whom this
ordinance of great self-denial has been imposed. But the people, the
voters themselves, must understand that their emancipation brings
its duties and responsibilities. It costs a great deal of money properly
to enlighten the electorate upon the issues of a Presidential
campaign, as it is of the very essence of good government that the
voter should make his choice with understanding. Knowledge is
necessary, it is to his interest that he have it, and he should pay the
cost of putting it within his reach. The corporations and the
“interests” have been relieved of this burden of expense. Let the men
of the parties assume it, willingly, for their own benefit, for the benefit
of all. Campaign committees must spend money, yet if at the close of
the campaign they are left with heavy debts, it will not be long before
we lapse into the old, bad conditions. Campaigns can be “financed”
with the money of the voters. A multitude of small individual
contributions will fill the campaign chest, and candidates and party
will be under no obligations save to the people, and those it will be
their highest duty to fulfil.
IF LINCOLN COULD RETURN

(FIFTY YEARS AFTER EMANCIPATION)

O N Sunday, September 22, in negro churches everywhere, men


and women of dark skin celebrated the fiftieth anniversary of
the first Emancipation Proclamation. It was an occasion which
might well have been made a day of heart-searching, to ask
ourselves whether, in our treatment of the negro, the nation as a
whole is honoring the memory of Lincoln himself, and of those who
labored, fought, and died to abolish slavery. Are we, as a nation,
dealing fairly with the negro? Or is “The Independent” correct when it
declares that of all our ninety millions there are none to-day so
oppressed as the race that Lincoln freed?
In this number of THE CENTURY we group examples of the work of
four members of the race,—in prose, poetry, art, and musical
composition, the first being a paper of entire authoritativeness and
singular moderation of tone. In it Dr. Washington, with the dauntless
faith and courage which have carried him so far, sets forth his
answer to the question whether the American negro is having a fair
chance. Discouragement he will not admit; he fixes his eyes ever
upon the hopeful signs. When he goes abroad it seems to him the
working-classes of Europe are worse off than our own colored
people, whose accessions from abroad are proof to him that the
negro fares nowhere else so well.
That Dr. Washington serves a useful purpose in ever presenting
the cheerful side, is obvious. But he who fifty years after
Emancipation would stop there would see but one side of the
question. The shadows upon the race which the head of Tuskegee
glides over so lightly lie heavily upon ever-growing numbers of
intellectual colored people, who are moved but little by figures of
increased negro farm holdings, by statistics about negro grocers,
lawyers, physicians, and teachers. Grateful as their hearts may be
that they are to-day in possession of their own bodies, they regard
the future with troubled eyes.
Looking upon their children they ask with panic fear if these are
to be the children of the ghettos now being established, set apart as
though leprous, with one avenue of advancement after another
closed to them, denied the participation in government guaranteed to
them by law, and in some States put beyond the pale of law. They
read that the American Bar Association has virtually drawn the color
line. They read almost every week of men of their race burned at the
stake, North and South; of their women, done to death, ruthlessly
shot out of semblance to their Maker, by the mobs that destroy them
in the name of the purity of the white race! They read that even
Northern communities where the mob rules, like Coatesville,
Pennsylvania, and Springfield, Illinois, once the very home of
Lincoln, fail to punish those who defy the laws and slay the accused
or the innocent with barbarities known in no other land. They see
themselves left out of account in the South by a leader of a new
political party that boasts its desire for “social justice.” If their
children, deprived of school by the thousands, and depressed and
ignorant, without a single influence to uplift, go wrong, the imputed
shame is that of the whole race. Every negro criminal becomes a
living indictment of his people. Bitterest of all, they cannot defend
themselves against official wrong-doing, for having only a phantom
ballot in their hands, the vilest sheriff is beyond their reach.
Moreover, to the injury of the whole body-politic, no adequate
education through self-government is provided for them in this
Republic of Lincoln.
This is the reverse of the picture and its pathos is beyond
description. What would Lincoln say? Would he, if reembodied,
declare that the negro, for all his progress, is having a fair chance,
North or South, to-day?
ON THE RELATIVE CLAIMS OF SWEETNESS AND
LIGHT
To One who Thinks Women “Movement-Mad”

Dear Helen:
A cowardly fear of being funny silenced me last night, but, now,
refreshed by sleep and by your absence, knowing that you are well
on your road, I mount my slow nag, and, armored to be dull, come
pricking after. I know that words are creatures of chance, subject to
jeopardy from all the winds that blow, and that in writing I am only
increasing the hazard of misunderstanding, “harnessing for a yet
more perilous adventure,” but despite this I follow soberly behind,
your own words upon my lips.
You said, in part, you may recall, that our little group, and
especially the women among us, are movement-mad; that peaceful,
esthetic conversation has been done to death by furious talk on
wrongs and reforms; that the amenities of civilized society, so you
said, have fallen beneath the ax of chop-logic; that even at dinners
we women grow red and shrill over astonishing topics—eugenics,
political nominees, prison menus, and woman suffrage; that art, “the
world’s sweet inn,” has become a house of brawlers; that to speak of
dancing is to bring up in a dance-hall, and to discuss a play is to
become entangled in a wreckage of commandments. All of Pan’s
gay world is silenced, you declared, shut off with a cordon of linked
question marks; that the very laughter in our throats has become
brazen and controversial—the derisive laughter of the Hebrew
Scriptures; that, oh, dreadful climax, you will open your purse to no
more reforms, unless it be to a Society for the Reformation of
Manners.
When you quote Falstaff’s plaint that “It were better to be eaten to
death with rust than scoured to nothing with perpetual motion,” I
understand what you mean—that is my misfortune in debate. But are
you really enamoured of rust? You, who would keep all talk in low
relief, sweet, level, and cool as the heads on a Greek frieze, are you
not turning from a world that is alive and alight to wander in a land of
shades?
Esthetic ideals were shaped for us by the centuries that lie
between us and Myron. What wonder that talk moves smoothly upon
such age-worn ways! Slave-owning Greeks and subtle Italians
wrought out, in sweat and toil, arts that were old when a social
conscience was an amœba. In sweat and strife men and women are
blazing new trails to-day; and the overcoming of inertia still
generates heat. But, once more, something comes forth, shining,
from the lustration of fire.
Smile down upon us from your tranquil bleacher! It is quite true
that we are ravished by the dazzling, many-sided iridescence of what
we take for a new Truth, hailing its radiance with our uncouth cries.
We buffet hotly the ideas that each is driving toward his goal, but
when, out of the rush and turmoil, some one scores a touchdown the
whole field cheers.
When a new country is discovered—though it be a desert—the
explorer plants his flag with a shout; and there is as high authority, in
the authentic tribune of men’s hearts, for our passion as for your
calm. The “lark of aspiration” must sing as it mounts.
A modern master of friendship has said that, after all, there are
only two real subjects of conversation—love and conduct. As love is
best in tête-à-tête, that leaves us morals. Thinking of it in cold blood,
it seems as though we might be calmer talkers, but when have
morals not been associated with heat, here or hereafter? The part of
your charge that I find strangest is that this noisy super-heatedness,
that you impute to us, is a new evil. Where is your memory, Girl?
Mine takes up the thread about the year that you were born, when
people were still talking back over the questionable morality of one
set of men freeing the slaves of another set, and of the political right
of the Southern States to secede. I see a room, a hollow square of
books, the air blue with smoke, torn by lightning-jags of talk. Voices
—raised voices, dear Lady—talked of Predestination and Free Will.
They talked as we poor weaklings of this Laodicean age may never
hope to talk, hurling Eternal Damnation at each others’ heads and
imputations of blasphemy, in horrid whispers. Goethe’s Elective
Affinities and the doctrine of one Thomas Paine were discussed;
Darwin, in relation to the osteoplastic romance of Eve. Apostolic
Succession, Infant Damnation, Predestination—these are some of
the live-wires of another day. I never hear the echo of raised voices,
down the long vista of my past, without realizing that real talk is
going forward—morals, preferably with a dash of love.
To-day, we, true children of those senior wranglers, have
inescapably, in our blood, the passion for moral research; “the
invisible masters that reign in our innermost cells” have
predetermined our choice. The names of all the protagonists have
changed; the battleground has shifted from skyey metaphysics to the
slum street; from Infant Damnation to Certified Milk for Babies; but
we, too, are doing battle for our realities. In the hospitals and the
settlement houses are the children and grandchildren of our old
circuit-riders and militant bishops. The children of those who warred
for righteousness still seek and serve.
Your quarrel is not with our little group of noisy talkers; your
quarrel, Madam, is with the leaven of the world, that froths and
foams and stirs because it is working. In the stormy schools of
religious controversy—in that old, warm talk on morals, when the
souls of men were the stake—we learned that we are our brothers’
keepers, and that idea, once generated, will be conserved,
generation by generation, and the force of it will not be lost. As they
strove to insure to men eternal life, their children strive that men may
inherit the earth.
Our contention, yours and mine, is the old Hellenic-Hebraic clash
of ideals.
“Beauty and Light!” you cry.
“Justice and Right!” comes the response.
We are both right, but my right is deeper and more elemental
than yours. Yours exists for a few, happy, chosen spirits; mine for the
whole, wide travailing world. Yours rests upon mine; mine does not
rest upon yours.
“Rest!” you jeer. “You people never rest, and you let no one else
rest.”
“‘Restfulness,’” I cry, with inky vivacity, “Stevenson told us long
ago that ‘restfulness is a quality for cattle.’”

You might also like