Bash Books

Master Bash Programming with Free Books

Bash Programming Books

Bash (acronym for the ‘Bourne-Again-SHell’) is the GNU Project’s shell and programming language. It’s an sh-compatible shell that incorporates useful features from the Korn shell (ksh) and C shell (csh). Bash has become a de facto standard for shell scripting. It runs on almost all versions of Unix and a few other operating systems including Windows platforms.

A Unix shell is both a command interpreter and a programming language. As a command interpreter, the shell provides the user interface to various utilities. The programming language features of Bash allow these utilities to be combined. Files containing commands can be developed, and become commands themselves. A shell script is therefore a quick way of prototyping a complex application. Shell scripting follows the classic Unix philosophy of breaking complex projects into simpler subtasks, of chaining together components and utilities.

Like all Unix shells, Bash supports filename globbing (wildcard matching), piping, here documents, command substitution, variables and control structures for condition-testing and iteration. The keywords, syntax and other basic features of the language were all copied from sh. Other features, e.g., history, were copied from csh and ksh. Bash is a POSIX shell, but with a number of extensions.

We publish a series covering the best open source programming books for other popular languages. Read them here.

Advanced Bash Scripting Guide

Advanced Bash Scripting Guide

By Mendel Cooper (916 pages)

Advanced Bash-Scripting Guide is an in-depth exploration of the art of scripting. Almost the complete set of commands, utilities, and tools is available for invocation by a shell script.

The book explains:

  • Basics such as special characters, quoting, exit and exit status
  • Beyond the Basics including loops and branches, command substitution, arithmetric expansion, recess time
  • Commands – Internal commands and builtins; External filters, programs and commands; System and Administrative Commands
  • Advanced topics: Regular Expressons, Here Documents, I/O Redirection, Subshells, Restricted Shells, Process Substitution, Functions, Aliases, List Constructs, Arrays, Indirect References, /dev and /proc, Of Zeros and Nulls, Debugging, Options, Gotchas, Scripting with Style

This book is in the public domain.

Bash Reference Manual

GNU Bash Reference Manual

By Chet Ramey, Brian Fox (166 pages)

GNU Bash Reference Manual is the definitive reference for GNU Bash, the standard GNU command-line interpreter.

GNU Bash is a complete implementation of the POSIX2 shell specification (/bin/sh), with additional features from the C-shell (csh) and Korn shell (ksh). The name is an acronym for the ‘Bourne-Again SHell’, a pun on Stephen Bourne, the author of the direct ancestor of the current Unix shell sh, which appeared in the Seventh Edition Bell Labs Research version of Unix.

The book explores:

  • Basic Shell Features – briefly summarizes the shell’s ‘building blocks’: commands, control structures, shell functions, shell parameters, shell expansions, redirections, which are a way to direct input and output from and to named files, and how the shell executes commands
  • Shell Builtin Commands – briefly describes the builtins which Bash inherits from the Bourne Shell, as well as the builtin commands which are unique to or have been extended in Bash
  • Shell Variables – describes the shell variables that Bash uses. Bash automatically assigns default values to a number of variables
  • Bash Features – describes features unique to Bash
    • Invoking Bash – Command line options that you can give to Bash
    • Bash Startup Files – When and how Bash executes scripts
    • Interactive Shells – What an interactive shell is
    • Bash Conditional Expressions – Primitives used in composing expressions for the test builtin
    • Shell Arithmetic – Arithmetic on shell variables
    • Aliases – Substituting one command for another
    • Arrays – Array Variables
    • The Directory Stack – History of visited directories
    • Printing a Prompt – Controlling the PS1 string
    • The Restricted Shell – A more controlled mode of shell execution
    • Bash POSIX Mode – Making Bash behave more closely to what the POSIX standard specifies
  • Job Control – discusses what job control is, how it works, and how Bash allows you to access its facilities
  • Command Line Editing – describes the basic features of the GNU command line editing interface including readline interaction, bindable readline commands, and programmable completion
  • Using History Interactively – describes how to use the GNU History Library interactively, from a user’s standpoint
  • Installing Bash – provides basic instructions for installing Bash on the various supported platforms
Bash Guide for Beginners

Bash Guide for Beginners

By Machtelt Garrels (165 pages)

Everybody working on a UNIX or UNIX-like system who wants to make life easier on themselves, power users and sysadmins alike, can benefit from reading this book. Learn about Bash programming.


  • Bash scripts
  • Writing and debugging scripts
  • The bash environment: Shell initialization files, Variables, Quoting characters, Shell expansion, aliases
  • Regular expressions
  • sed stream editor
  • awk programming language
  • Conditional statements (if, if/then/else, if/then/elif/else, Nested if statements, Boolean operations)
  • Writing interactive scripts
  • Repetitive tasks
  • Functions
  • Catching signals

The book is released under an open source license.

The Linux Command Line

The Linux Command Line

By William D. Shotts, Jnr (540 pages)

The Linux Command Line includes an excellent primer on Bash scripting. It also offers a broad overview of ‘living’ on the Linux command line. Unlike some books that concentrate on just a single program, such as the shell, bash, this book will try to convey how to get along with the command line interface in a larger sense. How does it all work? What can it do? What’s the best way to use it?

The book is divided into the following parts:

  • Learning The Shell starts the exploration of the basic language of the command line including such things as the structure of commands, file system navigation, command line editing, and finding help and documentation for commands
  • Configuration And The Environment covers editing configuration files that control the computer’s operation from the command line
  • Common Tasks And Essential Tools explores many of the ordinary tasks that are commonly performed from the command line. Unix-like operating systems, such as Linux, contain many ‘classic’ command line programs that are used to perform powerful operations on data
  • Writing Shell Scripts introduces shell programming, an admittedly rudimentary, but easy to learn, technique for automating many common computing tasks. By learning shell programming, you will become familiar with concepts that can be applied to many other programming languages

The book is released under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported (CC BY-NC-ND 3.0) license.

Linux Shell Scripting Tutorial

Linux Shell Scripting Tutorial

By Vivek Gite and Contributors (294 pages)

The book starts by describing Linux and simple scripts to automate frequently executed commands and moves on to describing conditional logic, user interaction, loops, menus, traps, and functions. The book ends with various sys administration related scripts such as making a backup, using cron jobs, writing interactive tools, web based tools, remote login, ftp and database backup related scripts.

The book is aimed at system administrators and students. It teachers the reader how to read, write, and debug Linux shell scripts using the Bash shell.

Linux Shell Scripting Tutorial is available under the Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported license.

The Bash Guide

The Bash Guide

By Maarten Billemont (HTML)

The Bash Guide teaches both newcomers and long-time users the best, safest and most robust ways of writing powerful bash programming scripts as well as making efficient and speedy interactive use of the shell.

The book explores:

  • Inception – an introduction to bash, installing and starting it; the terminal, the keyboard and the display; programs, processes and how their flow of information is connected
  • Commands and Arguments – what a command is, and how to issue them; interactive mode and scripts; command syntax, searching commands and programs by name; arguments and word splitting as well as input and output redirection
  • Variables and Expansions – Bash parameters and variables; environment variables, special parameters and array parameters; expanding parameters, expansion operators, command substitution and process substitution; pathname expansion, tilde expansion and brace expansion
  • Tests and Conditionals – exit codes, success and failure, testing files, strings and numbers, handling different conditions, conditional operators and conditional compound commands

This guide is open source, licensed under Creative Commons Attribution-ShareAlike 4.0 International License (CC-BY-SA). It’s a work-in-progress.


Ada, Assembly, Awk, Bash, C, C++, C#, Clojure, CoffeeScript, ECMAScript, Erlang, Forth, Fortran, Go, Haskell, HTML, Java, JavaScript, LaTeX, Lisp, Logo, Lua, OCaml, Pascal, Perl, PHP, Prolog, Python, R, Ruby, Rust, Scala, Scheme, Scratch, SQL, Swift, TeX, VimL

Click to rate this software
[Total: 0 Average: 0]

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.