What is the Difference between Terminal and Shell on Linux?

Share
When talking about terminal commands and the command-line on Linux, we often encounter two terms that seem to be used interchangeably but are distinct: terminal and shell—and this can be very confusing—after all, what is the difference between them?

The terminal emulator, or simply "terminal," is the application with the graphical user interface. It's program that displays the terminal window. It decides the size of the text in the terminal and the color of the text, for example. It may or may not support tabs. Every desktop environment seems to have its own terminal. GNOME has GNOME Terminal, KDE has Konsole, Xfce has Xfce Terminal, and so on.

The shell is the program that actually interprets the text you type in the terminal. The default shell on many Linux distributions is GNU's Bash. Because Linux is a kernel, and Bash is the shell, such distros may be called GNU/Linux.

When you type a command on GNOME Terminal, or Konsole, or Xfce Terminal, the program that actually interprets the command is Bash. This means the command is always going to work the exactly same way no matter in which terminal emulator you type it, because the program interpreting it isn't GNOME Terminal or Konsole, it's Bash.

Similarly, when you run a shell script, the file is read by a shell program, not by a terminal program.

Each shell may interpret commands in completely different ways, since they are different programs. Fortunately, shells generally work exactly the same way, supporting exactly the same syntax, so a basic command typed in one shell should work in other shells without problem. However, more advanced syntax tends to vary from shell to shell.

It's not unusual for developers to write shell scripts that only work in Bash because the script uses syntactic features that only Bash supports (also called Bashisms). If you take a script that has Bashisms try to run it on a system that doesn't have bash as its shell, but perhaps the more lightweight ash shell instead, the script will stop working when it encounters a feature that exists in bash but not in ash.

Shells typically have names that end in sh, like bash, ash, dash, ltsh, zsh, etc. On Linux, /usr/bin/sh, or simply sh, is an alias for the default shell (e.g. for /usr/bin/bash).

Written by Noel Santos.

About the Author

I'm a self-taught Brazilian programmer graduated in IT from a FATEC. In a world of increasingly complex and essential computers, I decided to use my technical expertise in hardware, desktop applications, and web technologies to create an informative resource to make PC's easier to understand.

View Comments