Bash

    user@linux:~$ bash --help

What is Bash?

Bash is both the shell and scripting language of Linux and macOS, and is able to be installed on POSIX compliant operating systems such as BSD derivatives. When you interface with a linux terminal, you are using Bash, the Bourne-Again Shell. While linux is able to use multiple different shells at the command line, bash is by far the default and most popular option.

The Bourne-Again Shell

When you open a terminal, you are greeted by your name and location. This is configured using bash and all commands you enter are interpreted within bash. Changing your thinking from a graphical user interface to a terminal can be challenging, but graphical applications do the same process in reverse. When a command is inputted in the terminal, it is interpreted and that command interacts with the kernel. Using a shell is how a human can directly interact with a computer.

History of the Bash Shell

Bash was released in 1989, but has roots in 1977 at the release of sh Bourne Shell created by Stephen Bourne. The shell had the goal of being an interpreter for both direct interaction and scripting. The Bourne-Again Shell was designed to replace the Bourne Shell created by Brian Fox with GNU. The Bash shell added important features such as environment variables while also providing backwards compatibility with sh.

Bash the Scripting Language

Bash as a language functions just as Bash in the terminal. Using the same commands and saving them as scripts, developers are able to increase their efficiency on the terminal by running a script rather than procedurally typing a set of commands. When scripting in bash, you can use the shebang to declare what interpreter you want the system to use to execute the commands. This works similarly to how many system administrators write Python scripts, declaring which version of Python the application is written in to prevent errors at runtime. With Bash being an interpreted language, Bash requires no compiling to binary,

Common Bash commands

CommandFunction
lsList directory contents
pwdPrint working directory
cdChange directory
echoDisplay text
grepFind pattern
locateLocate file/directory
catConcatenate and print files
lessView contents of file
touchCreate file/update timestamp
mkdirMake new directory
manManual of …
mvMove/rename directory
cpCopy file/directory
rmRemove file/directory
rmdirRemove empty directory
chmodChange file/folder permissions
|Pipe output
killKill process

References

cs.lmu.edu - Introduction to Bash

IBM Developer - Evolution of shells in Linux

Medium - Bash Scripting

educative - Bash cheat sheet