The Linux Command Line, 2nd Edition

Book Description

The Linux Command Line takes you from your very first terminal keystrokes to writing full programs in Bash, the most popular Linux shell (or command line). Along the way you'll learn the timeless skills handed down by generations of experienced, mouse-shunning gurus: file navigation, environment configuration, command chaining, pattern matching with regular expressions, and more.

In addition to that practical knowledge, author William Shotts reveals the philosophy behind these tools and the rich heritage that your desktop Linux machine has inherited from Unix supercomputers of yore.

As you make your way through the book's short, easily-digestible chapters, you'll learn how to:

•Create and delete files, directories, and symlinks

•Administer your system, including networking, package installation, and process management

•Use standard input and output, redirection, and pipelines

•Edit files with Vi, the world's most popular text editor

•Write shell scripts to automate common or boring tasks

•Slice and dice text files with cut, paste, grep, patch, and sed

Once you overcome your initial ""shell shock,"" you'll find that the command line is a natural and expressive way to communicate with your computer. Just don't be surprised if your mouse starts to gather dust.

Table of Contents

  1. Cover Page
  2. Title Page
  3. Copyright Page
  4. Dedication
  5. About the Author
  6. About the Technical Reviewer
  7. BRIEF CONTENTS
  8. CONTENTS IN DETAIL
  9. ACKNOWLEDGMENTS
    1. First Edition
    2. Second Edition
  10. INTRODUCTION
    1. Why Use the Command Line?
    2. What This Book Is About
    3. Who Should Read This Book
    4. What’s in This Book
    5. How to Read This Book
    6. What’s New in the Second Edition
    7. Your Feedback Is Needed!
  11. PART I: LEARNING THE SHELL
  12. 1 WHAT IS THE SHELL?
    1. Terminal Emulators
    2. Making Your First Keystrokes
    3. Try Some Simple Commands
    4. Ending a Terminal Session
    5. Summing Up
  13. 2 NAVIGATION
    1. Understanding the File System Tree
    2. The Current Working Directory
    3. Listing the Contents of a Directory
    4. Changing the Current Working Directory
    5. Summing Up
  14. 3 EXPLORING THE SYSTEM
    1. More Fun with ls
    2. Determining a File’s Type with file
    3. Viewing File Contents with less
    4. Taking a Guided Tour
    5. Symbolic Links
    6. Hard Links
    7. Summing Up
  15. 4 MANIPULATING FILES AND DIRECTORIES
    1. Wildcards
    2. mkdir—Create Directories
    3. cp—Copy Files and Directories
    4. mv—Move and Rename Files
    5. rm—Remove Files and Directories
    6. ln—Create Links
    7. Building a Playground
    8. Summing Up
  16. 5 WORKING WITH COMMANDS
    1. What Exactly Are Commands?
    2. Identifying Commands
    3. Getting a Command’s Documentation
    4. Creating Our Own Commands with alias
    5. Summing Up
  17. 6 REDIRECTION
    1. Standard Input, Output, and Error
    2. Redirecting Standard Output
    3. Redirecting Standard Error
    4. Redirecting Standard Input
    5. Pipelines
    6. Summing Up
  18. 7 SEEING THE WORLD AS THE SHELL SEES IT
    1. Expansion
    2. Quoting
    3. Summing Up
  19. 8 ADVANCED KEYBOARD TRICKS
    1. Command Line Editing
    2. Completion
    3. Using History
    4. Summing Up
  20. 9 PERMISSIONS
    1. Owners, Group Members, and Everybody Else
    2. Reading, Writing, and Executing
    3. Changing Identities
    4. Exercising Our Privileges
    5. Changing Your Password
    6. Summing Up
  21. 10 PROCESSES
    1. How a Process Works
    2. Viewing Processes
    3. Controlling Processes
    4. Signals
    5. Shutting Down the System
    6. More Process-Related Commands
    7. Summing Up
  22. PART II: CONFIGURATION AND THE ENVIRONMENT
  23. 11 THE ENVIRONMENT
    1. What Is Stored in the Environment?
    2. How Is the Environment Established?
    3. Modifying the Environment
    4. Summing Up
  24. 12 A GENTLE INTRODUCTION TO VI
    1. Why We Should Learn vi
    2. A Little Background
    3. Starting and Stopping vi
    4. Editing Modes
    5. Moving the Cursor Around
    6. Basic Editing
    7. Search-and-Replace
    8. Editing Multiple Files
    9. Saving Our Work
    10. Summing Up
  25. 13 CUSTOMIZING THE PROMPT
    1. Anatomy of a Prompt
    2. Trying Some Alternative Prompt Designs
    3. Adding Color
    4. Moving the Cursor
    5. Saving the Prompt
    6. Summing Up
  26. PART III: COMMON TASKS AND ESSENTIAL TOOLS
  27. 14 PACKAGE MANAGEMENT
    1. Packaging Systems
    2. How a Package System Works
    3. Common Package Management Tasks
    4. Summing Up
  28. 15 STORAGE MEDIA
    1. Mounting and Unmounting Storage Devices
    2. Creating New File Systems
    3. Testing and Repairing File Systems
    4. Moving Data Directly to and from Devices
    5. Writing CD-ROM Images
    6. Summing Up
    7. Extra Credit
  29. 16 NETWORKING
    1. Examining and Monitoring a Network
    2. Transporting Files over a Network
    3. Secure Communication with Remote Hosts
    4. Summing Up
  30. 17 SEARCHING FOR FILES
    1. locate—Find Files the Easy Way
    2. find—Find Files the Hard Way
    3. Summing Up
  31. 18 ARCHIVING AND BACKUP
    1. Compressing Files
    2. Archiving Files
    3. Synchronizing Files and Directories
    4. Summing Up
  32. 19 REGULAR EXPRESSIONS
    1. What Are Regular Expressions?
    2. grep
    3. Metacharacters and Literals
    4. The Any Character
    5. Anchors
    6. Bracket Expressions and Character Classes
    7. POSIX Character Classes
    8. POSIX Basic vs. Extended Regular Expressions
    9. Alternation
    10. Quantifiers
    11. Putting Regular Expressions to Work
    12. Summing Up
  33. 20 TEXT PROCESSING
    1. Applications of Text
    2. Revisiting Some Old Friends
    3. Slicing and Dicing
    4. Comparing Text
    5. Editing on the Fly
    6. Summing Up
    7. Extra Credit
  34. 21 FORMATTING OUTPUT
    1. Simple Formatting Tools
    2. Document Formatting Systems
    3. Summing Up
  35. 22 PRINTING
    1. A Brief History of Printing
    2. Printing with Linux
    3. Preparing Files for Printing
    4. Sending a Print Job to a Printer
    5. Monitoring and Controlling Print Jobs
    6. Summing Up
  36. 23 COMPILING PROGRAMS
    1. What Is Compiling?
    2. Compiling a C Program
    3. Summing Up
  37. PART IV: WRITING SHELL SCRIPTS
  38. 24 WRITING YOUR FIRST SCRIPT
    1. What Are Shell Scripts?
    2. How to Write a Shell Script
    3. More Formatting Tricks
    4. Summing Up
  39. 25 STARTING A PROJECT
    1. First Stage: Minimal Document
    2. Second Stage: Adding a Little Data
    3. Variables and Constants
    4. Here Documents
    5. Summing Up
  40. 26 TOP-DOWN DESIGN
    1. Shell Functions
    2. Local Variables
    3. Keep Scripts Running
    4. Summing Up
  41. 27 FLOW CONTROL: BRANCHING WITH IF
    1. if Statements
    2. Exit Status
    3. Using test
    4. A More Modern Version of test
    5. (( ))—Designed for Integers
    6. Combining Expressions
    7. Control Operators: Another Way to Branch
    8. Summing Up
  42. 28 READING KEYBOARD INPUT
    1. read—Read Values from Standard Input
    2. Validating Input
    3. Menus
    4. Summing Up
    5. Extra Credit
  43. 29 FLOW CONTROL: LOOPING WITH WHILE/UNTIL
    1. Looping
    2. Breaking Out of a Loop
    3. Reading Files with Loops
    4. Summing Up
  44. 30 TROUBLESHOOTING
    1. Syntactic Errors
    2. Logical Errors
    3. Testing
    4. Debugging
    5. Summing Up
  45. 31 FLOW CONTROL: BRANCHING WITH CASE
    1. The case Command
    2. Summing Up
  46. 32 POSITIONAL PARAMETERS
    1. Accessing the Command Line
    2. Handling Positional Parameters en Masse
    3. A More Complete Application
    4. Summing Up
  47. 33 FLOW CONTROL: LOOPING WITH FOR
    1. for: Traditional Shell Form
    2. for: C Language Form
    3. Summing Up
  48. 34 STRINGS AND NUMBERS
    1. Parameter Expansion
    2. Arithmetic Evaluation and Expansion
    3. bc—An Arbitrary Precision Calculator Language
    4. Summing Up
    5. Extra Credit
  49. 35 ARRAYS
    1. What Are Arrays?
    2. Creating an Array
    3. Assigning Values to an Array
    4. Accessing Array Elements
    5. Array Operations
    6. Associative Arrays
    7. Summing Up
  50. 36 EXOTICA
    1. Group Commands and Subshells
    2. Traps
    3. Asynchronous Execution with wait
    4. Named Pipes
    5. Summing Up
  51. INDEX

Product Information

  • Title: The Linux Command Line, 2nd Edition
  • Author(s): William E. Shotts
  • Release date: February 2019
  • Publisher(s): No Starch Press
  • ISBN: 9781593279523