| |
| |
Dedication | |
| |
| |
Acknowledgments | |
| |
| |
Introduction | |
| |
| |
Why Use the Command Line? | |
| |
| |
What This Book Is About | |
| |
| |
Who Should Read This Book | |
| |
| |
What's in This Book | |
| |
| |
How to Read This Book | |
| |
| |
Prerequisites; Learning the Shell | |
| |
| |
| |
What Is the Shell? | |
| |
| |
| |
Terminal Emulators | |
| |
| |
| |
Your First Keystrokes | |
| |
| |
| |
Try Some Simple Commands | |
| |
| |
| |
Ending a Terminal Session | |
| |
| |
| |
Navigation | |
| |
| |
| |
Understanding the Filesystem Tree | |
| |
| |
| |
The Current Working Directory | |
| |
| |
| |
Listing the Contents of a Directory | |
| |
| |
| |
Changing the Current Working Directory | |
| |
| |
| |
Exploring the System | |
| |
| |
| |
More Fun with ls | |
| |
| |
| |
Determining a File's Type with file | |
| |
| |
| |
Viewing File Contents with less | |
| |
| |
| |
A Guided Tour | |
| |
| |
| |
Symbolic Links | |
| |
| |
| |
Manipulating Files and Directories | |
| |
| |
| |
Wildcards | |
| |
| |
| |
mkdir—Create Directories | |
| |
| |
| |
cp—Copy Files and Directories | |
| |
| |
| |
mv—Move and Rename Files | |
| |
| |
| |
rm—Remove Files and Directories | |
| |
| |
| |
ln—Create Links | |
| |
| |
| |
Let's Build a Playground | |
| |
| |
| |
Final Note | |
| |
| |
| |
Working with Commands | |
| |
| |
| |
What Exactly Are Commands? | |
| |
| |
| |
Identifying Commands | |
| |
| |
| |
Getting a Command's Documentation | |
| |
| |
| |
Creating Your Own Commands with alias | |
| |
| |
| |
Revisiting Old Friends | |
| |
| |
| |
Redirection | |
| |
| |
| |
Standard Input, Output, and Error | |
| |
| |
| |
Pipelines | |
| |
| |
| |
Final Note | |
| |
| |
| |
Seeing the World as the Shell Sees It | |
| |
| |
| |
Expansion | |
| |
| |
| |
Quoting | |
| |
| |
| |
Final Note | |
| |
| |
| |
Advanced Keyboard Tricks | |
| |
| |
| |
Command Line Editing | |
| |
| |
| |
Completion | |
| |
| |
| |
Using History | |
| |
| |
| |
Final Note | |
| |
| |
| |
Permissions | |
| |
| |
| |
Owners, Group Members, and Everybody Else | |
| |
| |
| |
Reading, Writing, and Executing | |
| |
| |
| |
Changing Identities | |
| |
| |
| |
Exercising Your Privileges | |
| |
| |
| |
Changing Your Password | |
| |
| |
| |
Processes | |
| |
| |
| |
How a Process Works | |
| |
| |
| |
Controlling Processes | |
| |
| |
| |
Signals | |
| |
| |
| |
More Process-Related Commands; Configuration and the Environment | |
| |
| |
| |
The Environment | |
| |
| |
| |
What Is Stored in the Environment? | |
| |
| |
| |
How Is the Environment Established? | |
| |
| |
| |
Modifying the Environment | |
| |
| |
| |
Final Note | |
| |
| |
| |
A Gentle Introduction to vi | |
| |
| |
| |
Why We Should Learn vi | |
| |
| |
| |
A Little Background | |
| |
| |
| |
Starting and Stopping vi | |
| |
| |
| |
Editing Modes | |
| |
| |
| |
Moving the Cursor Around | |
| |
| |
| |
Basic Editing | |
| |
| |
| |
Search and Replace | |
| |
| |
| |
Editing Multiple Files | |
| |
| |
| |
Saving Our Work | |
| |
| |
| |
Customizing the Prompt | |
| |
| |
| |
Anatomy of a Prompt | |
| |
| |
| |
Trying Some Alternative Prompt Designs | |
| |
| |
| |
Adding Color | |
| |
| |
| |
Moving the Cursor | |
| |
| |
| |
Saving the Prompt | |
| |
| |
| |
Final Note; Common Tasks and Essential Tools | |
| |
| |
| |
Package Management | |
| |
| |
| |
Packaging Systems | |
| |
| |
| |
How a Package System Works | |
| |
| |
| |
Common Package Management Tasks | |
| |
| |
| |
Final Note | |
| |
| |
| |
Storage Media | |
| |
| |
| |
Mounting and Unmounting Storage Devices | |
| |
| |
| |
Creating New Filesystems | |
| |
| |
| |
Testing and Repairing Filesystems | |
| |
| |
| |
Formatting Floppy Disks | |
| |
| |
| |
Moving Data Directly to and from Devices | |
| |
| |
| |
Creating CD-ROM Images | |
| |
| |
| |
Writing CD-ROM Images | |
| |
| |
| |
Extra Credit | |
| |
| |
| |
Networking | |
| |
| |
| |
Examining and Monitoring a Network | |
| |
| |
| |
Transporting Files over a Network | |
| |
| |
| |
Secure Communication with Remote Hosts | |
| |
| |
| |
Searching for Files | |
| |
| |
| |
locate—Find Files the Easy Way | |
| |
| |
| |
find—Find Files the Hard Way | |
| |
| |
| |
Archiving and Backup | |
| |
| |
| |
Compressing Files | |
| |
| |
| |
Archiving Files | |
| |
| |
| |
Synchronizing Files and Directories | |
| |
| |
| |
Regular Expressions | |
| |
| |
| |
What Are Regular Expressions? | |
| |
| |
| |
grep—Search Through Text | |
| |
| |
| |
Metacharacters and Literals | |
| |
| |
| |
The Any Character | |
| |
| |
| |
Anchors | |
| |
| |
| |
Bracket Expressions and Character Classes | |
| |
| |
| |
POSIX Basic vs. Extended Regular Expressions | |
| |
| |
| |
Alternation | |
| |
| |
| |
Quantifiers | |
| |
| |
| |
Putting Regular Expressions to Work | |
| |
| |
| |
Final Note | |
| |
| |
| |
Text Processing | |
| |
| |
| |
Applications of Text | |
| |
| |
| |
Revisiting Some Old Friends | |
| |
| |
| |
Slicing and Dicing | |
| |
| |
| |
Comparing Text | |
| |
| |
| |
Editing on the Fly | |
| |
| |
| |
Final Note | |
| |
| |
| |
Extra Credit | |
| |
| |
| |
Formatting Output | |
| |
| |
| |
Simple Formatting Tools | |
| |
| |
| |
Document Formatting Systems | |
| |
| |
| |
Final Note | |
| |
| |
| |
Printing | |
| |
| |
| |
A Brief History of Printing | |
| |
| |
| |
Printing with Linux | |
| |
| |
| |
Preparing Files for Printing | |
| |
| |
| |
Sending a Print Job to a Printer | |
| |
| |
| |
Monitoring and Controlling Print Jobs | |
| |
| |
| |
Compiling Programs | |
| |
| |
| |
What Is Compiling? | |
| |
| |
| |
Compiling a C Program | |
| |
| |
| |
Final Note; Writing Shell Scripts | |
| |
| |
| |
Writing Your First Script | |
| |
| |
| |
What Are Shell Scripts? | |
| |
| |
| |
How to Write a Shell Script | |
| |
| |
| |
More Formatting Tricks | |
| |
| |
| |
Final Note | |
| |
| |
| |
Starting a Project | |
| |
| |
| |
First Stage: Minimal Document | |
| |
| |
| |
Second Stage: Adding a Little Data | |
| |
| |
| |
Variables and Constants | |
| |
| |
| |
Here Documents | |
| |
| |
| |
Final Note | |
| |
| |
| |
Top-Down Design | |
| |
| |
| |
Shell Functions | |
| |
| |
| |
Local Variables | |
| |
| |
| |
Keep Scripts Running | |
| |
| |
| |
Final Note | |
| |
| |
| |
Flow Control: Branching with if | |
| |
| |
| |
Using if | |
| |
| |
| |
Exit Status | |
| |
| |
| |
Using test | |
| |
| |
| |
A More Modern Version of test | |
| |
| |
| |
(( ))—Designed for Integers | |
| |
| |
| |
Combining Expressions | |
| |
| |
| |
Control Operators: Another Way to Branch | |
| |
| |
| |
Final Note | |
| |
| |
| |
Reading Keyboard Input | |
| |
| |
| |
read—Read Values from Standard Input | |
| |
| |
| |
Validating Input | |
| |
| |
| |
Menus | |
| |
| |
| |
Final Note | |
| |
| |
| |
Extra Credit | |
| |
| |
| |
Flow Control: Looping with while and until | |
| |
| |
| |
Looping | |
| |
| |
| |
while | |
| |
| |
| |
Breaking out of a Loop | |
| |
| |
| |
until | |
| |
| |
| |
Reading Files with Loops | |
| |
| |
| |
Final Note | |
| |
| |
| |
Troubleshooting | |
| |
| |
| |
Syntactic Errors | |
| |
| |
| |
Logical Errors | |
| |
| |
| |
Testing | |
| |
| |
| |
Debugging | |
| |
| |
| |
Final Note | |
| |
| |
| |
Flow Control: Branching with case | |
| |
| |
| |
case | |
| |
| |
| |
Final Note | |
| |
| |
| |
Positional Parameters | |
| |
| |
| |
Accessing the Command Line | |
| |
| |
| |
Handling Positional Parameters En Masse | |
| |
| |
| |
A More Complete Application | |
| |
| |
| |
Final Note | |
| |
| |
| |
Flow Control: Looping with for | |
| |
| |
| |
for: Traditional Shell Form | |
| |
| |
| |
for: C Language Form | |
| |
| |
| |
Final Note | |
| |
| |
| |
Strings and Numbers | |
| |
| |
| |
Parameter Expansion | |
| |
| |
| |
Arithmetic Evaluation and Expansion | |
| |
| |
| |
bc—An Arbitrary-Precision Calculator Language | |
| |
| |
| |
Final Note | |
| |
| |
| |
Extra Credit | |
| |
| |
| |
Arrays | |
| |
| |
| |
What Are Arrays? | |
| |
| |
| |
Creating an Array | |
| |
| |
| |
Assigning Values to an Array | |
| |
| |
| |
Accessing Array Elements | |
| |
| |
| |
Array Operations | |
| |
| |
| |
Final Note | |
| |
| |
| |
Exotica | |
| |
| |
| |
Group Commands and Subshells | |
| |
| |
| |
Traps | |
| |
| |
| |
Asynchronous Execution | |
| |
| |
| |
Named Pipes | |
| |
| |
| |
Final Note | |
| |
| |
Colophon | |
| |
| |
Updates | |