Shell Fundamentals

As described in the previous section, when a terminal is opened it runs software that provides access to the computer's operating system. This software has became known as "the shell". Let's take a quick at how that name came to be used.

At a high level, operating systems are designed with two distinct parts:

  1. A first part which contains the low-level software that has complete control of system resources.

  2. A second part which "surrounds" the first to prevent access to it, except for specific, pre-defined actions that application software are allowed to take.

This concept has been visualized as a nut contained within its shell, where the meat of the nut (the "kernel") contains the low-level software, and the hard shell that surrounds it prevents outside access except for specific, pre-defined "system calls", such as those defined by "the Linux API.

With this in mind, when users open a terminal they are presented with an application that accepts commands that are typed in the terminal, executes them, and returns the output to the terminal interface. This application provides users an interface to make system calls, call other applications, and execute scripts that define higher-level interactions with the operating system. Since these "shell applications" allow users to interact directly with the shell, they have become synonymous with "the shell".

On Linux systems, the most common shell application is Bash, which is often installed by default, though other popular shell applications include ksh, zsh, and fish. Since Bash is the most common shell we will use it for examples, but most shells feature backwards-compatibility with Bash so most examples should work across other shells.

As terminals evolved from hardware to software, the boundaries between the terminal and the shell became increasingly blurred, to the point where the concepts of "the terminal", a "terminal emulator", "the console", and "the shell" have become interchangeable in many conversations, which has led to confusion about what each term actually refers to. Possibly the most common term for these concepts among users is "the command-line", which is the topic of the next section.