Last Updated on 11/25/2023 by dboth
I use Bash all the time, in part because it is the default shell for most Linux distributions, including Fedora and CentOS, the ones I normally use. However I also use Bash because it is an excellent shell and it has a large number of features to make life easier for the Lazy SysAdmin.
Features like tab completion, command line recall and editing, shortcuts like aliases, and more all contribute to its value as a powerful shell. One of my favorite Bash features is that, although it uses Emacs mode for command line editing by default, that can be changed to Vi mode so that I can use editing commands that are already part of my muscle memory.
But if we think of Bash solely as a shell we miss much of its true power. While researching Bash for my three-volume Linux self-study course1, upon which this series of articles is based. I learned things about Bash that I never knew in over 20 years of working with Linux. Some of these new bits of knowledge relate to its use as a programming language. Bash is a powerful programming language, one perfectly designed for use on the command line and in shell scripts. For this series we are exploring its use on the command line interface (CLI).
Let’s start with a few basics.
What is a shell?
A shell is the command interpreter for for the operating system. Each of the many shells available for Linux interprets the commands typed by the user or SysAdmin into a form usable by the operating system. When the results are returned to the shell program, it displays them on the terminal. All of the shells with which I am familiar are also programming languages.
Bash stands for Bourne Again Shell because the Bash shell is based upon the older Bourne shell which was written by Steven Bourne in 1977. Many other shells are available.2 The four I list here are the ones I encounter most frequently but many others exist.
- csh – the C shell for programmers who like the syntax of the C language.
- ksh – the Korn shell, written by David Korn and popular with Unix users.
- tcsh – a version of csh with more ease of use features.
- zsh – which combines many features of other popular shells.
All shells have some built-in commands that supplement or replace the commands provided by the core utilities. Open the man page for Bash and find the “BUILT-INS” section to see the list of commands provided by the shell itself.
I have used the C shell, the Korn shell and the Z shell. I still like the Bash shell more than any of the others I have tried. Each shell has its own personality and syntax. Some will work better for you and others not so well. Use the one that works best for you, but that might require that you at least try some of the others. You can change shells quite easily.
All of these shells are programming languages as well as a command interpreter.
This list of links contains all of the articles in this series about Bash.
- Learning Bash and How to Program It. An introduction to this series.
- Programming Bash: Getting Started
- Programming Bash: Logical Operators
- Programming Bash: Loops
- Automation With Bash Scripts: Getting Started
- Automation With Bash Scripts: Creating a template
- Automation With Bash Scripts: Bash Program Needs Help
- Automation With Bash Scripts: Initialization and sanity testing
- Both, David, Using and Administering Linux – Zero to SysAdmin, 2nd Edition, Apress, 2023, Vol 2, Chs 28 and 29. ↩︎
- Wikipedia, Comparison of command shells, https://en.wikipedia.org/wiki/Comparison_of_command_shells ↩︎