bash
Start a new Bash shell
TLDR
Start an interactive shell session
Start an interactive shell session without loading startup configs
Execute specific [c]ommands
Execute a specific script
E[x]ecute a specific script, printing each command before executing it
Execute a specific script and stop at the first [e]rror
Execute specific commands from stdin
Start a [r]estricted shell session
SYNOPSIS
bash [options] [file [arguments...]]
bash -c command [arguments...]
PARAMETERS
-a
Export all declared variables to the environment.
-b
Notify of job termination immediately (same as notify).
-c string
Read and execute commands from the following string argument.
-D list
Dump translatable strings matching list pattern; used for localization.
-d
Placeholder for future use (currently no effect).
-i
Force shell to run interactively, even if input/output not terminals.
-l, --login
Invoke as a login shell, reading login startup files.
-m, --monitor
Enable job control (default if interactive).
-n
Read commands but do not execute (syntax check).
-r, --restricted
Start restricted shell: limits features like changing directories.
-s, --read-stdin
Read commands from standard input (default if no file).
-u
Treat unset variables as error when substituting.
-v, --verbose
Print shell input lines as read.
-x, --xtrace
Print commands and arguments as executed.
--debugger
Enable debugger mode for scripts.
--dump-po-strings
Equivalent to -D with all strings for .pot files.
--help
Display usage information and exit.
--init-file file
Use file as initialization file instead of ~/.bashrc.
--noediting
Do not use command-line editing features.
--noprofile
Do not read /etc/profile or user profile files.
--norc
Do not read ~/.bashrc (or --rcfile).
--posix
Turn on POSIX mode.
--protected-mode
Enable protected mode for source builtin.
--rcfile file
Use file as resource file instead of ~/.bashrc.
--version
Print version information and exit.
DESCRIPTION
Bash (Bourne-Again SHell) is a powerful command-line shell and scripting language for Unix-like systems, developed by the GNU Project as a free replacement for the Bourne shell (sh). First released in 1989, it has become the default shell on most Linux distributions and Apple macOS.
Bash extends POSIX shell standards with advanced features including command-line editing (Emacs and vi keybindings), tab completion, command history and recall, job control, aliases, shell functions, indexed arrays, arithmetic expansion, brace expansion, and process substitution. It supports both interactive use for executing commands and non-interactive scripting for automation tasks.
Invoked as an interactive shell, Bash reads startup files like ~/.bashrc for configuration. Scripts begin with #!/bin/bash. It handles pipelines, redirections, loops, conditionals, and signal handling robustly. Bash is highly scriptable, widely used in system administration, DevOps, and software development pipelines.
CAVEATS
Bash is not fully POSIX-compliant by default; use --posix for compliance. Restricted mode (-r) severely limits functionality. Some options ignored in login shells. Large scripts may impact performance due to feature-rich parsing.
STARTUP FILES
Login shells read /etc/profile, then ~/.bash_profile or ~/.bash_login or ~/.profile. Interactive non-login: ~/.bashrc.
KEY FEATURES
History (history), tab completion, aliases (alias), functions, arrays (declare -a), brace expansion {a..z}, coprocs.
HISTORY
Developed by Brian Fox in 1989 for GNU Project as sh replacement. Maintained by Chet Ramey since 1992. Key milestones: version 2.0 (1996) added arrays; 4.0 (2009) improved completion; 5.0 (2019) enhanced pattern matching. Version 5.2.26 current as of 2024; widely used since Linux adoption in 1990s.


