Terminal, Shell, Bash: What’s the Difference?

For anyone new to web development, the command-line can be puzzling. Graphical interfaces have been the norm since the mid-1990s, yet tutorials assume you’ll be comfortable typing commands into a text window — and freely swap between the words terminal, command-line, shell, and bash as if they all mean the same thing. This article explains why developers still rely on the command-line, clears up the terminology, and shows how these concepts fit together.


What is a Terminal?

Before personal computers and graphical interfaces became widespread in the 1990’s, users interacted with a central computer through a dedicated physical device called a computer terminal — a keyboard for input and a screen for output, connected to a shared mainframe.

Physical terminals are long gone from everyday use, but modern operating systems replicate the experience through terminal emulators — applications that provide the same text input and output within a standard desktop window. The terminal emulator is simply the application providing the window. The shell is the separate program running inside it.


What is a Shell

A shell is any program that exposes the services of the operating system to the user or to other programs. It is, essentially, the interface of the operating system. Shells come in two broad forms: graphical and command-line.


Why “Shell”?

The term shell comes from thinking of an operating system like a nut: the kernel is the hard core at the centre, responsible for managing hardware and system resources, and the outer shell is a program that provides access to those resources via the kernel’s API. In other words, the shell sits between you and the operating system.

Graphical-based shells

When using a modern desktop computer, most people interact with a graphical shell without thinking of it in those terms. Applications like Windows Explorer or Finder on macOS are graphical shells that allow you to navigate the file system, move, copy, and delete files, and launch applications by clicking and dragging icons. Under the hood, these actions are still calling operating system services via the kernel.

Command-line shells

Before graphical interfaces became widespread, all of these tasks were performed by typing text commands into a physical computer terminal. The program loaded onto the terminal to interpret those typed commands was called the shell. This is the kind of shell most developers are referring to when they use the term today.


A brief history of Unix Shells

Modern operating systems including Linux and macOS are based on Unix, and the command-line shells written for Unix decades ago are still in active use today.

Bourne shell

The Bourne shell (sh) was created in 1979 for Version 7 Unix. As well as allowing users to type commands interactively, it introduced the ability to write shell scripts — text files containing a sequence of commands that could be executed automatically. Many of the popular shells used today are based on Bourne and are described as Bourne compatible. A script written for the Bourne shell will generally run without modification on any Bourne-compatible shell.

Bash (Bourne-Again shell)

Bash (Bourne-again shell) was created in 1989 as a free, open-source, and feature-enhanced replacement for the Bourne shell. It became the default shell on Linux, macOS, and was distributed with Cygwin for Windows. Bash’s dominance as the default shell for so long is why the words bash and shell are still routinely used interchangeably — though strictly speaking, Bash is one particular shell among many.

Bash remained macOS’s default shell until 2019, when Apple stopped bundling the latest version due to licensing concerns (Bash version 4 and above uses the GPL v3 licence, which Apple does not ship). macOS now only includes the older Bash 3.2, and has replaced Bash as the default with zsh.

zsh (Z shell)

Zsh (Z shell) was created in 1990, just a year after Bash. It is fully Bourne compatible, shares many features with Bash, and adds further enhancements of its own. For most of its life it was a niche choice — it was, for example, the default shell on the Commodore Amiga — but it made a significant comeback when Apple adopted zsh as the default shell in macOS Catalina (2019). If you’re on a Mac today, zsh is almost certainly the shell your terminal is running.


Terminal vs Shell: What’s the Difference?

This is a common source of confusion. To put it simply:

  • The terminal (or terminal emulator) is the application that provides a window for text input and output. On macOS, the built-in app is called Terminal; popular alternatives include iTerm2 and Warp.
  • The shell is the program running inside that window, interpreting the commands you type.

When you open Terminal on a Mac, it launches a terminal emulator and then loads your default shell (zsh, unless you’ve changed it). You can use any terminal emulator you like and configure it to load whichever shell you prefer — the two are independent of each other.


What Is a Login Shell?

Historically, when physical terminals were used to access a shared mainframe, the login shell was the shell that loaded at startup to prompt the user for credentials and then apply their personal profile and configuration settings.

On a modern computer you’re already logged in when you open a terminal emulator, so the explicit login process is skipped but the profile and configuration files that a login shell would have read are still loaded automatically. The term login shell is now commonly used to mean the default shell that loads when a terminal is opened.

Login shells still have a practical use when connecting to remote machines and can be explicitly invoked using a flag on your shell commands or scripts.

Secure Shell (SSH)

Despite the name, Secure Shell (SSH) is not a shell interpreter. It is a network protocol used to securely authenticate and connect to a remote computer, allowing you to run commands on that machine as if you were sitting at its terminal. Once connected over SSH, you are dropped into a shell on the remote system but SSH itself is the secure tunnel, not the shell.

More information can be found in this guide to Secure Shell (SSH)


Why use a command-line shell on modern operating systems

Physical computer terminals were superseded by personal computers with graphical interfaces decades ago, but command-line interfaces and shell scripts remain essential tools for developers offering automation, precision, and control that graphical interfaces simply cannot match. Modern operating systems make these capabilities available through terminal emulators: software that replicates the behaviour of a physical terminal within a standard desktop window.

On macOS, the built-in option is the aptly named Terminal, though many developers prefer third-party alternatives such as iTerm2 or Warp. Whichever emulator you choose, you can configure it to load whichever shell you prefer as the default.

What shells are available on my computer?

Bash and zsh are two of the most common shells but there are many more text-based shells available. On a Mac or Linux machine you can list all installed shells by running:

cat /etc/shells

This will return something like:

/bin/bash
/bin/csh
/bin/dash
/bin/ksh
/bin/sh
/bin/tcsh
/bin/zsh

Changing default shell on Mac terminal

To change your default shell on MacOS or Linux, enter the chsh command and provide one of the paths listed in /etc/shells. For example to switch to Bash enter the following:

$ chsh -s /bin/bash

Configure your shell

When configuring your preferred shell you can add your preferences, environment variables and aliases to the following related config files

  • zsh —> .zshrc or .zprofile
  • bash —> .bashrc or .bashprofile

If you’d like help getting started with shell configuration, Oh My Zsh is a popular framework for managing zsh configuration, and Oh My Bash provides the equivalent for Bash users.

Adding other shells to my computer

You can install shells beyond those shipped with your OS. For example, to install Fish (a shell known for its user-friendly features), follow the instructions at fishshell.com. Once installed, its path (e.g. /bin/fish) will be added to /etc/shells, making it available as a default shell or for running Fish scripts.


Running shell scripts

Bash vs Zsh compatibility

This is an area that causes a lot of confusion, often compounded by forum answers that aren’t quite accurate.

Both Bash and zsh are backwards compatible with Bourne meaning a script written for the original Bourne shell will run on either. However, Bash and zsh each have their own additional commands and features that are not mutually compatible. A script that uses Bash-specific syntax will not necessarily run correctly in zsh, and vice versa.

The solution is the shebang line at the top of a script. This tells the operating system which shell interpreter to use for that particular script, regardless of what your default shell is:

#!/bin/bash

When you run a script containing this line, the OS checks /etc/shells to confirm that Bash is available and then uses it to execute the script even if your terminal’s default shell is zsh. The shell you use interactively in your terminal and the shell used to run a given script are entirely independent.

If no shebang line is present, the script will be run by your default shell, which may or may not produce the expected results.


Shell in web development

When tutorials and documentation for web development tools refer to “the shell”, they almost always mean a Unix-style command-line shell — and in many cases they are specifically thinking of Bash. If you’re on macOS or Linux you’ll be well served by whichever shell is your default. Windows developers can access a compatible environment via Windows Subsystem for Linux (WSL), which installs a full Linux shell environment directly on Windows.


Further reading


Posted

in

, ,

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *