Skip to main content
Engineering LibreTexts

01-B.13: Shells: What and Why

  • Page ID
    26789
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)\(\newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    The Shell

    A Linux shell is a command-line interpreter or shell that provides a command line user interface for Linux operating systems. The shell is both an interactive command language and a scripting language, which can be used by the operating system to control the execution of the system using shell scripts.

    Users typically interact with a Linux shell using a terminal emulator; however, direct operation via serial hardware connections or Secure Shell are common for server systems. All Unix shells provide filename wildcarding, piping, here documents, command substitution, variables and control structures for condition-testing and iteration.

    The shell sits between the Linux applications, including the Linux terminal app/keyboard, and the kernel (think of operating system). So when a command is entered in a terminal window, the shell interprets what is being requested and hands the request off to the kernel, which then interfaces with the hardware if necessary. If the commands are in a script file (we will get to this later), the shell reads each line of the script, executing the commands and presenting the output as necessary

    The Linux shell sits on top of the operating system. There are several layers to the shell - each on a bit more removed from the operating system level of control.
    Figure \(\PageIndex{1}\):Linux Shell. ("Linux Shell" by Patrick McClanahan is licensed under CC BY-SA 4.0)

    There is actually a great deal going on in this image. First of all, the hardware is at the center, and surrounded by the Linux Kernel. The shell must interact with the kernel in order to interface with the hardware. The purple ring represents the various shells that are available to the Linux user: bash, k shell, c shell, z shell and the original shell. The shells all interface with the kernel. The blue ring shows only some of the commands available to a user. Linux commands interface with the shell, which passes the requests to the kernel which then performs the necessary operations, including any interactions with the hardware if required.

    There are numerous shells available; below we list several of them to give you an idea of the diversity.

    Shell Details
    Bourne Shell - denoted as sh Written by Steve Bourne at AT&T Bell Labs. It is the original UNIX shell. It is faster and more preferred, but lacks features for interactive use like the ability to recall previous commands.
    C shell - denoted as csh Created by Bill Joy at the University of California at Berkeley. It incorporated features such as aliases and command history and includes helpful programming features like built-in arithmetic and C-like expression syntax.
    Korn shell - denoted as ksh Written by David Korn at AT&T Bell Labs. It is a superset of the Bourne shell and supports everything in the Bourne shell. It has interactive features. It includes features like built-in arithmetic and C-like arrays, functions, and string-manipulation facilities. It is faster than C shell and compatible with script written for C shell.
    Bash shell - denoted as bash The Bourne Again Shell was originally released in 1989. Bash has grown to easily become the most used shell across the Linux world, and it is commonly found in other unix-like operating systems as well.
    Tcsh - denoted as tcsh A derivative of csh, the Berkely Unix C shell, which sports a very long lineage back to the early days of Unix and computing itself.
    zsh zsh originated in the early 90's and sports a number of useful features, including spelling correction, theming, namable directory shortcuts, sharing your command history across multiple terminals, and various other slight tweaks from the original Bourne shell.

    This page titled 01-B.13: Shells: What and Why is shared under a CC BY-SA 4.0 license and was authored, remixed, and/or curated by Patrick McClanahan.

    • Was this article helpful?