Questions specific to GNU’s Bourne Again SHell, as opposed to other Bourne/POSIX shells. For questions about Unix shells in general, use the /shell tag instead. For shell scripts with errors/syntax errors, please check them with the shellcheck program (or in the web shellcheck server at https://shellcheck.net) before posting here.
Bash (the GNU Bourne Again SHell) is a Unix shell. It was built as a free replacement to the Bourne shell and includes many scripting features from other shells, such as ksh and (t)csh. When called as sh
, it is intended to conform to the POSIX 1003.1 standard. Bash features include: command line editing with the readline library, command history, job control, functions & aliases, arrays, dynamic prompts, integer arithmetic, and command & filename completion. Bash is the default interactive shell on most Linux distributions and is usually available on other Unix variants. Some GNU/Linux systems even use it as the default shell /bin/sh
.
Because Bash is a common shell, you may be using it by default, so beware the temptation to choose this tag by default! Use bash only if your question is about Bash-specific syntax or the interactive use of Bash. Use the tag shell instead if your question is about a sh
(Bourne or POSIX) script. Use shell-script if you have a question about a shell’s interaction with other programs.
Before asking for help about problems with Bash scripts, consider debugging the script yourself first.
Related tags
- shell Many shell-agnostic questions are of interest to Bash users.
- shell-script For questions about shell scripting in general
Other shells
- ksh - the Korn shell
- csh - the C shell
- tcsh - the TENEX C shell
- zsh - the Z shell
- dash - the Debian Almquist shell
- fish - the friendly interactive shell
Features related to Bash
- wildcards (or globbing): matching files based on their name
- command-history a history of commands that can be navigated with the Up and Down keys, searched, etc.; also a recall mechanism based on expanding sequences beginning with
!
- autocomplete completion of partially-entered file names, command names, options and other arguments
- prompt showing a prompt before each command, which many users like to customize
- readline the GNU library implementing the line editing and history handling in Bash (and other terminal applications like
gdb
andpython
) - alias for defining shortcuts for frequently-used commands
- array a data structure for storing items in index-able memory
Bash reference material
- Bash GNU project web page
- Bash maintainer's web page
- Bash FAQ by the maintainer, Chet Ramey
Sampling of Bash-related Unix.SE questions:
- Why does my shell script choke on whitespace or other special characters?
- What are the shell's control and redirection operators?
- Is there a ".bashrc" equivalent file read by all shells?
- What features are in zsh and missing from bash, or vice versa?
- Change directory without typing cd?
- Understanding the exclamation mark (!) in bash
- Preserve bash history in multiple terminal windows
- Bash autocomplete in ssh session
- How do I clear Bash's cache of paths to executables?
- Command-line completion from command history
- In Bash, when to alias, when to script, and when to write a function?
- How to do integer & float calculations, in bash or other languages/frameworks?
- Why is my bash prompt getting bugged when I browse the history? (and other editing weirdness)
Books and other resources
- Bash Reference Manual
- Advanced Bash-Scripting Guide (PDF)
- Bash Guide for Beginners (PDF)
- Lhunath's Bash Guide
- Bash Pocket Reference, 2nd Edition
- Bash Cookbook, 2nd Edition
- Learning the Bash Shell, 3rd Edition
- The Command Line Crash Course (appendix to "Learn Python the Hard Way")
- Linux Shell Scripting Tutorial
- The Art of Command Line