Linux Command Line and Shell Scripting Bible, 4th Edition

WIley, 2021

by Richard Blum and Christine Bresnahan


Advance your understanding of the Linux command line with this invaluable resource

Linux Command Line and Shell Scripting Bible, 4th Edition is the newest installment in the indispensable series known to Linux developers all over the world. Packed with concrete strategies and practical tips, the latest edition includes brand-new content covering:

Understanding the Shell
Writing Simple Script Utilities
Producing Database, Web & Email Scripts
Creating Fun Little Shell Scripts
Written by accomplished Linux professionals Christine Bresnahan and Richard Blum, Linux Command Line and Shell Scripting Bible, 4th Edition teaches readers the fundamentals and advanced topics necessary for a comprehensive understanding of shell scripting in Linux. The book is filled with real-world examples and usable scripts, helping readers navigate the challenging Linux environment with ease and convenience.

The book is perfect for anyone who uses Linux at home or in the office and will quickly find a place on every Linux enthusiastís bookshelf.

Table of Contents

Part I. The Linux Command Line
1. Starting with Linux Shells
Investigating Linux
Looking into the Linux kernel
The GNU utilities
The Linux desktop environment
Exploring Linux Distributions
Core Linux distributions
Specialized Linux distributions
Linux Live USB

2. Getting to the Shell
Reaching the Command Line
Console terminals
Graphical terminals
Accessing CLI via a Linux Console Terminal
Accessing CLI via Graphical Terminal Emulation
Using the GNOME Terminal Emulator
Accessing the GNOME Terminal
The menu bar
Using the Konsole Terminal Emulator
Accessing the Konsole Terminal
The menu bar
Using the xterm Terminal Emulator
Accessing xterm
Command line parameters

3. Basic Bash Shell Commands
Starting the Shell
Using the Shell Prompt
Interacting with the Bash Manual
Navigating the Filesystem
Looking at the Linux filesystem
Traversing directories
Listing Files and Directories
Displaying a basic listing
Displaying a long listing
Filtering listing output
Handling Files
Creating files
Copying files
Using auto-tab completion.
Linking files
Renaming files
Deleting files
Managing Directories
Creating directories
Deleting directories
Viewing File Contents
Viewing the file type
Viewing the whole file
Viewing parts of a file

4. More Bash Shell Commands
Monitoring Programs
Peeking at the processes
Real-time process monitoring
Stopping processes
Viewing Disk Space
Mounting media
Using the df command
Using the du command
Working with Data Files
Sorting data
Searching for data
Compressing data
Archiving data

5. Understanding the Shell
Investigating Shell Types
Exploring Parent and Child Relationships
Looking at process lists
Creatively using subshells
Understanding External and Built-in Commands
Looking at external commands
Looking at built-in commands

6. Using Linux Environment Variables
Exploring Environment Variables?
Looking at global environment variables
Looking at local environment variables
Setting User-Defined Variables
Setting local user-defined variables
Setting global environment variables
Removing Environment Variables
Uncovering default Shell Environment Variables
Setting the PATH Environment Variable
Locating System Environment Variables
Understanding the login shell process
Understanding the interactive shell process
Understanding the non-interactive shell process
Making environment variables persistent
Learning about Variable Arrays

7. Understanding Linux File Permissions
Exploring Linux Security
The /etc/passwd file
The /etc/shadow file
Adding a new user
Removing a user
Modifying a user
Using Linux Groups
The /etc/group file
Creating new groups
Modifying groups
Decoding File Permissions
Using file permission symbols
Default file permissions
Changing Security Settings
Changing permissions
Changing ownership
Sharing Files

8. Managing Filesystems
Exploring Linux Filesystems
Digging into journaling filesystems
Looking at the ext4 filesystem
Looking at the IBM Journaling filesystem (JFS)
Looking at the XFS filesystem
Understanding Volume Managing filesystems
Looking at the ZFS filesystem
Looking at the Btrfs filesystem
Looking at Stratis

Working with FileSystems
Creating partitions
Create a filesystem
Checking and repairing a filesystem
Managing Logical Volumes
Exploring logical volume management layout
Understanding the LVM in Linux
Using the Linux LVM

9. Installing Software
Exploring Package Management
Inspecting the Debian-based Systems
Managing packages with apt
Installing software packages with apt
Updating software packages with apt
Uninstalling software with apt
The apt repositories
Understanding snap
Investigating the Red Hat-based Systems
Listing installed packages
Installing software with yum
Updating software with yum
Uninstalling software with yum
Yum repositories
Understanding Flatpacks
Installing from Source Code

10. Working with editors
Visiting the vim Editor
Checking your vim package
Exploring vim basics
Editing data
Copying and pasting
Searching and substituting
Navigating the nano Editor
Exploring the emacs Editor
Checking your emacs package
Editing data
Copying and pasting
Searching and replacing
Using buffers in emacs
Using windows in console mode emacs
Exploring the KDE Family of Editors
Looking at the KWrite editor
Looking at the Kate editor
Exploring the GNOME Editor
Starting gedit
Understanding basic gedit features
Setting preferences

Part II. Shell Scripting Basics
11. Basic Script Building
Using Multiple Commands
Creating a Script File
Displaying Messages
Using Variables
Environment variables
User variables
Command Substitution
Redirecting Input and Output
Output redirection
Input redirection
Employing Pipes
Performing Math
The expr command
Using brackets
A floating-point solution
Exiting the Script
Checking the exit status
The exit command
Working through a Practical Example

12. Using Structured Commands
Working with the if-then Statement
Exploring with the if-then Statement
Nesting ifs
Trying the test Command
Using numeric comparisons
Using string comparisons
Using file comparisons
Considering Compound Testing
Working with Advanced if-then Features
Using single parentheses
Using double parentheses
Using double brackets
Considering the case Command
Working through a Practical Example

13. More Structured commands
Looking at the for Command
Reading values in a list
Reading complex values in a list
Reading a list from a variable
Reading values from a command
Changing the field separator
Reading a directory using wildcards
Trying the C-Style for Command
The C language for command
Using multiple variables
Exploringhe while Command
Basic while format
Using multiple test commands
Using the until Command
Nesting Loops
Looping on File Data
Controlling the Loop
The break command
The continue command
Processing the Output of a Loop
Working through a few Practical Examples

14. Handling User Input
Passing Parameters
Reading parameters
Reading the script name
Testing parameters
Using Special Parameter Variables
Counting parameters
Grabbing all the data
Being Shifty
Working with Options
Finding your options
Using the getopt command
Advancing to getopt
Standardizing Options
Getting User Input
Reading Basics
Timing out
Reading with no display
Reading from a file
Working through a Practical Example

15. Presenting Data
Understanding Input and Output
Standard file descriptors
Redirecting errors
Redirecting Output in Scripts
Temporary redirections
Permanent redirections
Redirecting Input in Scripts
Creating Your Own Redirection
Creating output file descriptors
Redirecting file descriptors
Creating input file descriptors
Creating a read/write file descriptor
Closing file descriptors
Listing Open File Descriptors
Suppressing Command Output
Using Temporary Files
Creating a local temporary file
Creating a temporary file in /tmp
Creating a temporary directory
Logging Messages
Working through a Practical Example

16. Script Control
Handling Signals
Signaling the Bash Shell
Generating signals
Trapping signals
Trapping a script exit
Modifying or Removing a trap
Running Scripts in Background Mode
Running in the background
Running multiple background jobs
Running Scripts without a Hang-up
Controlling the Job
Viewing jobs
Restarting stopped jobs
Being Nice
Using the nice command
Using the renice command
Running like Clockwork
Scheduling a job using the at command
Using the batch command
Scheduling regular scripts
Starting scripts with a new shell
Working through a Practical Example

Part III. Advanced Shell Scripting
17. Creating Functions
Exploring Basic Script Functions
Creating a function
Using functions
Returning a Value
The default exit status
Using the return command
Using function output
Using Variables in Functions
Passing parameters to a function
Handling variables in a function
Investigating Array Variables and Functions
Passing arrays to functions
Returning arrays from functions
Considering Function Recursion
Creating a Library
Using Functions on the Command Line
Creating functions on the command line
Defining functions in the .bashrc file
Working through a Practical Example
Downloading and installing
Building the library

18. Writing Scripts for Graphical Desktops
Creating Text Menus
Create the menu layout
Create the menu functions
Add the menu logic
Putting it all together
Using the select command
Doing Windows
The dialog package
The dialog options
Using the dialog command in a script
Getting Graphic
The KDE environment
The GNOME environment
Working through a Practical Example

19. Introducing sed and gawk
Manipulating Text
Getting to know the sed editor
Getting to know the gawk program
Looking at sed Editor Basic Commands
Introducing more substitution options
Substituting flabs
Replacing characters
Using addresses
Addressing the numeric line
Using text pattern filters
Grouping commands
Deleting lines
Inserting and appending text
Changing lines
Transforming Characters
Printing Revisited
Printing lines
Printing line numbers
Listing lines
Using files with sed
Writing to a file
Reading data from a file
Working through a Practical Example

20. Regular expressions
Exploring Regular Expressions
A definition
Types of regular expressions
Defining BRE Patterns
Plain text
Special characters
Anchor characters
The dot character
Character classes
Negating character classes
Using ranges
Special character classes
The asterisk
Trying out Extended Regular Expressions
The question mark
The plus sign
Using braces
The pipe symbol
Grouping expressions
Viewing Regular Expressions in Action
Counting directory files
Validating a phone number
Parsing an email address
Working through a Practical Example

21. Advanced sed
Looking at Multiline Commands
Navigating the next commands
Navigating the multiline delete command
Navigating the multiline print command
Holding Space
Negating a Command
Changing the Flow
Replacing via a Pattern
Using the ampersand
Replacing sed output
Using sed in Scripts
Using wrappers
Redirecting sed output
Creating sed Utilities
Spacing with Double lines
Spacing files that may have blanks
Numbering lines in a file
Printing last lines
Deleting lines
Removing HTML tags
Working through a Practical Example

22. Advanced gawk
Using Variables
Built-in variables
User-defined variables
Working with Arrays
Defining array variables
Iterating through array variables
Deleting array variables
Considering Patterns
Regular expressions
The matching operator
Mathematical expressions
Structured Commands
The if statement
The while statement
The do-while statement
The for statement
Printing with Formats
Using Built-in Functions
Mathematical functions
String functions
Time functions
Trying out User-defined Functions
Defining a function
Using your functions
Creating a function library
Working through a Practical Example

23. Working with Alternative Shells
Considering the dash shell
Looking at the dash Shell Features
The dash command line parameters
The dash environment variables
The dash built-in commands
Scripting in dash
Creating dash scripts
Things that donít work
Exploring The zsh shell
Viewing parts of the zsh shell
Shell options
Built-in commands
Scripting with zsh
Mathematical operations
Structured commands

Part IV. Creating and Managing Practical Scripts
24. Writing Script Utilities
Performing Backups
Obtaining the required functions
Creating the script
Running the script
Auditing your System
Obtaining the required functions
Creating the script
Running the script
Monitoring your Systems
Obtaining the required functions
Creating the script
Running the script
25. Getting Organized
Understanding Version Control
Managing Your Scripts with Git
Installing Git
Setting up a Git Environment
Committing Scripts with Git
Updating Scripts with Git

Apendix A. - Quick guide to Bash commands
Apendix B. - Quick guide to sed & gawk commands


No comments posted yet. Add a comment

Useful Web sites:


Here's where I keep up to date on the latest Linux distribution news.

The most popular desktop Linux distribution.

A popular full-featured Linux distribution, great for both desktops and servers.

A popular Linux server distribution.

Web Programming

PHP online manual
The ultimate resource in all PHP programming topics

MySQL online manual
The MySQL database online manual.

A great online tutorial and reference for many Web programming languages.

Bass Guitar

Fender basses
One of my favorites, I love the Fender Jazz bass. It's such a versatile instrument you can take it to just about any gig!

Lakland basses
The Lakland Skyline 55-01 bass is yet another of my favorite basses!

Bible Study

Reformed Theological Seminary
When I'm not reading computer books, I'm doing bible studies. The Reformed Theological Seminary has some great online courses for free that cover the basics of reformed theology.
A smorgasbord of more reformed and evangelical seminary course recordings, all for free!