Efficient Linux at the Command Line

Book description

Take your Linux skills to the next level! Whether you're a system administrator, software developer, site reliability engineer, or enthusiastic hobbyist, this practical, hands-on book will help you work faster, smarter, and more efficiently. You'll learn how to create and run complex commands that solve real business problems, process and retrieve information, and automate manual tasks.

You'll also truly understand what happens behind the shell prompt, so no matter which commands you run, you can be more successful in everyday Linux use and more competitive on the job market.

As you build intermediate to advanced command-line skills, you'll learn how to:

  • Choose or construct commands that get your work done quickly
  • Run commands efficiently and navigate the Linux filesystem with ease
  • Build powerful, complex commands out of simpler ones
  • Transform text files and query them like databases to achieve business goals
  • Control Linux point-and-click features from the command line

Publisher resources

View/Submit Errata

Table of contents

  1. Preface
    1. What You’ll Learn
    2. What This Book Is Not
    3. Audience and Prerequisites
    4. Your Shell
    5. Conventions Used in This Book
    6. Using Code Examples
    7. O’Reilly Online Learning
    8. How to Contact Us
    9. Acknowledgments
  2. I. Core Concepts
  3. 1. Combining Commands
    1. Input, Output, and Pipes
    2. Six Commands to Get You Started
      1. Command #1: wc
      2. Command #2: head
      3. Command #3: cut
      4. Command #4: grep
      5. Command #5: sort
      6. Command #6: uniq
    3. Detecting Duplicate Files
    4. Summary
  4. 2. Introducing the Shell
    1. Shell Vocabulary
    2. Pattern Matching for Filenames
    3. Evaluating Variables
      1. Where Variables Come From
      2. Variables and Superstition
      3. Patterns Versus Variables
    4. Shortening Commands with Aliases
    5. Redirecting Input and Output
    6. Disabling Evaluation with Quotes and Escapes
    7. Locating Programs to Be Run
    8. Environments and Initialization Files, the Short Version
    9. Summary
  5. 3. Rerunning Commands
    1. Viewing the Command History
    2. Recalling Commands from the History
      1. Cursoring Through History
      2. History Expansion
      3. Never Delete the Wrong File Again (Thanks to History Expansion)
      4. Incremental Search of Command History
    3. Command-Line Editing
      1. Cursoring Within a Command
      2. History Expansion with Carets
      3. Emacs- or Vim-Style Command-Line Editing
    4. Summary
  6. 4. Cruising the Filesystem
    1. Visiting Specific Directories Efficiently
      1. Jump to Your Home Directory
      2. Move Faster with Tab Completion
      3. Hop to Frequently Visited Directories Using Aliases or Variables
      4. Make a Big Filesystem Feel Smaller with CDPATH
      5. Organize Your Home Directory for Fast Navigation
    2. Returning to Directories Efficiently
      1. Toggle Between Two Directories with “cd -”
      2. Toggle Among Many Directories with pushd and popd
    3. Summary
  7. II. Next-Level Skills
  8. 5. Expanding Your Toolbox
    1. Producing Text
      1. The date Command
      2. The seq Command
      3. Brace Expansion (A Shell Feature)
      4. The find Command
      5. The yes Command
    2. Isolating Text
      1. grep: A Deeper Look
      2. The tail Command
      3. The awk {print} Command
    3. Combining Text
      1. The tac Command
      2. The paste Command
      3. The diff Command
    4. Transforming Text
      1. The tr Command
      2. The rev Command
      3. The awk and sed Commands
    5. Toward an Even Larger Toolbox
    6. Summary
  9. 6. Parents, Children, and Environments
    1. Shells Are Executable Files
    2. Parent and Child Processes
    3. Environment Variables
      1. Creating Environment Variables
      2. Superstition Alert: “Global” Variables
    4. Child Shells Versus Subshells
    5. Configuring Your Environment
      1. Rereading a Configuration File
      2. Traveling with Your Environment
    6. Summary
  10. 7. 11 More Ways to Run a Command
    1. List Techniques
      1. Technique #1: Conditional Lists
      2. Technique #2: Unconditional Lists
    2. Substitution Techniques
      1. Technique #3: Command Substitution
      2. Technique #4: Process Substitution
    3. Command-as-String Techniques
      1. Technique #5: Passing a Command as an Argument to bash
      2. Technique #6: Piping a Command to bash
      3. Technique #7: Executing a String Remotely with ssh
      4. Technique #8: Running a List of Commands with xargs
    4. Process-Control Techniques
      1. Technique #9: Backgrounding a Command
      2. Technique #10: Explicit Subshells
      3. Technique #11: Process Replacement
    5. Summary
  11. 8. Building a Brash One-Liner
    1. Get Ready to Be Brash
      1. Be Flexible
      2. Think About Where to Start
      3. Know Your Testing Tools
    2. Inserting a Filename into a Sequence
    3. Checking Matched Pairs of Files
    4. Generating a CDPATH from Your Home Directory
    5. Generating Test Files
    6. Generating Empty Files
    7. Summary
  12. 9. Leveraging Text Files
    1. A First Example: Finding Files
    2. Checking Domain Expiration
    3. Building an Area Code Database
    4. Building a Password Manager
    5. Summary
  13. III. Extra Goodies
  14. 10. Efficiency at the Keyboard
    1. Working with Windows
      1. Instant Shells and Browsers
      2. One-Shot Windows
      3. Browser Keyboard Shortcuts
      4. Switching Windows and Desktops
    2. Web Access from the Command Line
      1. Launching Browser Windows from the Command Line
      2. Retrieving HTML with curl and wget
      3. Processing HTML with HTML-XML-utils
      4. Retrieving Rendered Web Content with a Text-Based Browser
    3. Clipboard Control from the Command Line
      1. Connecting Selections to stdin and stdout
      2. Improving the Password Manager
    4. Summary
  15. 11. Final Time-Savers
    1. Quick Wins
      1. Jumping Into Your Editor from less
      2. Editing Files That Contain a Given String
      3. Embracing Typos
      4. Creating Empty Files Quickly
      5. Processing a File One Line at a Time
      6. Identifying Commands That Support Recursion
      7. Read a Manpage
    2. Longer Learning
      1. Read the bash Manpage
      2. Learn cron, crontab, and at
      3. Learn rsync
      4. Learn Another Scripting Language
      5. Use make for Nonprogramming Tasks
      6. Apply Version Control to Day-to-Day Files
    3. Farewell
  16. A. Linux Refresher
    1. Commands, Arguments, and Options
    2. The Filesystem, Directories, and Paths
    3. Directory Movement
    4. Creating and Editing Files
    5. File and Directory Handling
    6. File Viewing
    7. File Permissions
    8. Processes
    9. Viewing Documentation
    10. Shell Scripts
    11. Becoming the Superuser
    12. Further Reading
  17. B. If You Use a Different Shell
  18. Index
  19. About the Author

Product information

  • Title: Efficient Linux at the Command Line
  • Author(s): Daniel J. Barrett
  • Release date: February 2022
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9781098113407