Glossary

bash

Also known as: Bourne Again Shell

bash (the GNU Bourne Again Shell) is the default interactive and scripting shell on the great majority of Linux distributions. Written by Brian Fox and later maintained by Chet Ramey for the GNU project, it is an extended, backwards-compatible replacement for the original Bourne shell (sh). It adds command-line editing (emacs and vi modes), command history, job control, directory stack, arrays, associative arrays, process substitution, and brace expansion.

A typical interactive session uses bash's history, tab completion, and line editing extensively:

history | grep git
!!                       # run the last command
!$                       # last argument of last command
Ctrl+R                   # reverse history search
Ctrl+A, Ctrl+E           # jump to start/end of line

Configuration lives in ~/.bashrc (interactive non-login shells) and ~/.bash_profile or ~/.profile (login shells), plus system-wide /etc/bash.bashrc and /etc/profile. The distinction between login and non-login shells is a historical wrinkle that continues to trip up new users.

For scripting, bash goes well beyond POSIX sh, offering features that justify the #!/bin/bash shebang. But its many rough edges—quoting, word splitting, untrapped errors—make it a tricky scripting language for non-trivial work, and tools like shellcheck are strongly recommended.

Related terms: Shell, zsh

Discussed in:

Also defined in: Textbook of Linux