You are previewing Linux Command Line and Shell Scripting Bible, 3rd Edition.
O'Reilly logo
Linux Command Line and Shell Scripting Bible, 3rd Edition

Book Description

Talk directly to your system for a faster workflow with automation capability

Linux Command Line and Shell Scripting Bible is your essential Linux guide. With detailed instruction and abundant examples, this book teaches you how to bypass the graphical interface and communicate directly with your computer, saving time and expanding capability. This third edition incorporates thirty pages of new functional examples that are fully updated to align with the latest Linux features. Beginning with command line fundamentals, the book moves into shell scripting and shows you the practical application of commands in automating frequently performed functions. This guide includes useful tutorials, and a desk reference value of numerous examples.

The Linux command line allows you to type specific shell commands directly into the system to manipulate files and query system resources. Command line statements can be combined into short programs called shell scripts, a practice increasing in popularity due to its usefulness in automation. This book is a complete guide providing detailed instruction and expert advice working within this aspect of Linux.

  • Write simple script utilities to automate tasks

  • Understand the shell, and create shell scripts

  • Produce database, e-mail, and web scripts

  • Study scripting examples ranging from basic to advanced

  • Whether used as a tutorial or as a quick reference, this book contains information that every Linux user should know. Why not learn to use the system to its utmost capability? Linux is a robust system with tremendous potential, and Linux Command Line and Shell Scripting Bible opens the door to new possibilities.

    Table of Contents

    1. Cover Page
    2. Title Page
    3. Copyright
    4. About the Authors
    5. About the Technical Editor
    6. Credits
    7. Acknowledgments
    8. Contents at a Glance
    9. Contents
    10. Introduction
    11. Part I: The Linux Command Line
      1. Chapter 1: Starting with Linux Shells
        1. What Is Linux?
        2. Linux Distributions
        3. Summary
      2. Chapter 2: Getting to the Shell
        1. Reaching the Command Line
        2. Accessing CLI via a Linux Console Terminal
        3. Accessing CLI via Graphical Terminal Emulation
        4. Using the GNOME Terminal Emulator
        5. Using the Konsole Terminal Emulator
        6. Using the xterm Terminal Emulator
        7. Summary
      3. Chapter 3: Basic bash Shell Commands
        1. Starting the Shell
        2. Using the Shell Prompt
        3. Interacting with the bash Manual
        4. Navigating the Filesystem
        5. Listing Files and Directories
        6. Handling Files
        7. Managing Directories
        8. Viewing File Contents
        9. Summary
      4. Chapter 4: More bash Shell Commands
        1. Monitoring Programs
        2. Monitoring Disk Space
        3. Working with Data Files
        4. Summary
      5. Chapter 5: Understanding the Shell
        1. Exploring Shell Types
        2. Exploring Parent and Child Shell Relationships
        3. Understanding Shell Built-In Commands
        4. Summary
      6. Chapter 6: Using Linux Environment Variables
        1. Exploring Environment Variables
        2. Setting User-Defined Variables
        3. Removing Environment Variables
        4. Uncovering Default Shell Environment Variables
        5. Setting the PATH Environment Variable
        6. Locating System Environment Variables
        7. Learning about Variable Arrays
        8. Summary
      7. Chapter 7: Understanding Linux File Permissions
        1. Linux Security
        2. Using Linux Groups
        3. Decoding File Permissions
        4. Changing Security Settings
        5. Sharing Files
        6. Summary
      8. Chapter 8: Managing Filesystems
        1. Exploring Linux Filesystems
        2. Working with Filesystems
        3. Managing Logical Volumes
        4. Summary
      9. Chapter 9: Installing Software
        1. Package Management Primer
        2. The Debian-Based Systems
        3. The Red Hat–Based Systems
        4. Installing from Source Code
        5. Summary
      10. Chapter 10: Working with Editors
        1. Visiting the vim Editor
        2. Navigating the nano Editor
        3. Exploring the emacs Editor
        4. Exploring the KDE Family of Editors
        5. Exploring the GNOME Editor
        6. Summary
    12. Part II: Shell Scripting Basics
      1. Chapter 11: Basic Script Building
        1. Using Multiple Commands
        2. Creating a Script File
        3. Displaying Messages
        4. Using Variables
        5. Redirecting Input and Output
        6. Pipes
        7. Performing Math
        8. Exiting the Script
        9. Summary
      2. Chapter 12: Using Structured Commands
        1. Working with the if-then Statement
        2. Exploring the if-then-else Statement
        3. Nesting ifs
        4. Trying the test Command
        5. Considering Compound Testing
        6. Working with Advanced if-then Features
        7. Considering the case Command
        8. Summary
      3. Chapter 13: More Structured Commands
        1. The for Command
        2. The C-Style for Command
        3. The while Command
        4. The until Command
        5. Nesting Loops
        6. Looping on File Data
        7. Controlling the Loop
        8. Processing the Output of a Loop
        9. Practical Examples
        10. Summary
      4. Chapter 14: Handling User Input
        1. Passing Parameters
        2. Using Special Parameter Variables
        3. Being Shifty
        4. Working with Options
        5. Standardizing Options
        6. Getting User Input
        7. Summary
      5. Chapter 15: Presenting Data
        1. Understanding Input and Output
        2. Redirecting Output in Scripts
        3. Redirecting Input in Scripts
        4. Creating Your Own Redirection
        5. Listing Open File Descriptors
        6. Suppressing Command Output
        7. Using Temporary Files
        8. Logging Messages
        9. Practical Example
        10. Summary
      6. Chapter 16: Script Control
        1. Handling Signals
        2. Running Scripts in Background Mode
        3. Running Scripts without a Hang-Up
        4. Controlling the Job
        5. Being Nice
        6. Running Like Clockwork
        7. Summary
    13. Part III: Advanced Shell Scripting
      1. Chapter 17: Creating Functions
        1. Basic Script Functions
        2. Returning a Value
        3. Using Variables in Functions
        4. Array Variables and Functions
        5. Function Recursion
        6. Creating a Library
        7. Using Functions on the Command Line
        8. Following a Practical Example
        9. Summary
      2. Chapter 18: Writing Scripts for Graphical Desktops
        1. Creating Text Menus
        2. Doing Windows
        3. Getting Graphic
        4. Summary
      3. Chapter 19: Introducing sed and gawk
        1. Manipulating Text
        2. Commanding at the sed Editor Basics
        3. Summary
      4. Chapter 20: Regular Expressions
        1. What Are Regular Expressions?
        2. Defining BRE Patterns
        3. Extended Regular Expressions
        4. Regular Expressions in Action
        5. Summary
      5. Chapter 21: Advanced sed
        1. Looking at Multiline Commands
        2. Holding Space
        3. Negating a Command
        4. Changing the Flow
        5. Replacing via a Pattern
        6. Placing sed Commands in Scripts
        7. Creating sed Utilities
        8. Summary
      6. Chapter 22: Advanced gawk
        1. Using Variables
        2. Working with Arrays
        3. Using Patterns
        4. Structured Commands
        5. Formatted Printing
        6. Built-In Functions
        7. User-Defined Functions
        8. Working through a Practical Example
        9. Summary
      7. Chapter 23: Working with Alternative Shells
        1. What Is the dash Shell?
        2. The dash Shell Features
        3. Scripting in dash
        4. The zsh Shell
        5. Parts of the zsh Shell
        6. Scripting with zsh
        7. Summary
    14. Part IV: Creating Practical Scripts
      1. Chapter 24: Writing Simple Script Utilities
        1. Performing Archives
        2. Managing User Accounts
        3. Monitoring Disk Space
        4. Summary
      2. Chapter 25: Producing Scripts for Database, Web, and E-Mail
        1. Using a MySQL Database
        2. Using the Web
        3. Using E-Mail
        4. Summary
      3. Chapter 26: Creating Fun Little Shell Scripts
        1. Sending a Message
        2. Obtaining a Quote
        3. Generating an Excuse
        4. Summary
    15. Appendix A: Quick Guide to bash Commands
    16. Appendix B: Quick Guide to sed and gawk
    17. Index