Bash

Bash is the shell, or command language interpreter, for the GNU operating system.

What is Bash?

Bash (short for Bourne-Again SHell) is a Unix shell and command language that is commonly used on Linux and macOS systems. It provides a command-line interface for users to interact with the operating system and execute commands.

What can you do with Bash?

With Bash, you can navigate the file system, execute commands, and automate repetitive tasks using scripts. It also provides features such as input/output redirection, piping, and command substitution, which allow you to combine commands and perform complex operations.

Is Bash the only shell available on Unix systems?

No, there are many other shells available on Unix systems, including zsh, csh, and tcsh. However, Bash is one of the most popular and widely used shells due to its versatility and ease of use.

Can you use Bash on Windows?

Yes, you can use Bash on Windows through the Windows Subsystem for Linux (WSL) feature. This allows you to install a Linux distribution on your Windows machine and run Bash commands and scripts natively.

What resources are available to learn Bash?

There are many resources available to learn Bash, including online tutorials, books, and video courses. The Bash documentation, which is included with most Unix systems, provides a comprehensive reference for the language and its features. There are also many community-driven resources, such as forums and blogs, where you can find tips and best practices for using Bash.

Snippet from Wikipedia: Bash (Unix shell)

Bash, short for Bourne-Again SHell, is a shell program and command language supported by the Free Software Foundation and first developed by Brian Fox for the GNU Project. Designed as a 100% free software alternative for the Bourne shell, it was initially released in 1989. Its moniker is a play on words, referencing both its predecessor, the Bourne shell, and the concept of renewal.

Since its inception, Bash has gained widespread adoption and is commonly used as the default login shell for numerous Linux distributions. It holds historical significance as one of the earliest programs ported to Linux by Linus Torvalds, alongside GCC (GNU Compiler Collection). It is available on nearly all modern operating systems, making it a versatile tool in various computing environments.

As a command processor, Bash operates within a text window where users input commands to execute various tasks. It also supports the execution of commands from files, known as shell scripts, facilitating automation. In keeping with Unix shell conventions, Bash incorporates a rich set of features, including:

  • Interactive and non-interactive invocation
  • Execution of:
    • External (to the shell) UNIX-style commands, such as `ls` and `ln`
    • Internal commands such as built-ins or functions, and
    • Files containing such commands, i.e., "shell scripts"
  • Command history, jobs / job control and tab completion in interactive mode
  • A built-in "help" command, man page, and an info page
  • Shell compatibility and portability (POSIX) modes
  • Control structures for condition-testing and iteration
  • UNIX-style pipelines
  • Configurable execution environment(s)
  • Command line parsing
    • Quoting rules
    • Parameters (or "variables"), arrays and associative arrays
    • "Command," arithmetic and "process" substitutions
    • "Word splitting"
    • Filename expansion (globbing) and pattern matching
    • Quote removal
  • Command name lookup, including "aliases," "functions," shell built-ins and shell keywords
  • Redirections of inputs, outputs and error data streams, including "here documents" and "here strings"
  • Subshells
  • Exit status codes
  • Signaling as a means of inter-process communication
  • Asynchronous execution
  • ANSI-C quoting
  • Brace and tilde expansions
  • Configurable prompt and command line editing with GNU readline in interactive mode
  • Shell and session startup files (dotfiles) such as '~/.bashrc'
  • Various settings and shell options with the `set` and `shopt` built-ins
  • Execution traces ("xtrace"): lightweight logging for debugging purposes

The keywords, syntax, dynamically scoped variables and other basic features of the language are all copied from sh. Other features, e.g., history, are copied from csh and ksh. Bash is a POSIX-compliant shell, but with a number of extensions.

A version is also available for Windows 10 and Windows 11 via the Windows Subsystem for Linux. It is also the default user shell in Solaris 11. Bash was also the default shell in BeOS, and in versions of Apple macOS from 10.3 (originally, the default shell was tcsh) to 10.15 (macOS Catalina), which changed the default shell to zsh, although Bash remains available as an alternative shell.

A security hole in Bash dating from version 1.03 (August 1989), dubbed Shellshock, was discovered in early September 2014 and quickly led to a range of attacks across the Internet. Patches to fix the bugs were made available soon after the bugs were identified.

GitHub Topics

Bash (Bourne Again Shell) is a shell and command language interpreter for the GNU operating system. It is meant to be an improved version of Bourne Shell.