What is the difference: terminal / console / shell?
You might have heard the terms terminal
, console
, tty
, shell
and asked yourself: Isn’t this all the same? Here is some more info…
TL;DR
terminal
- user interface for input, output and some extra taskstty
- a device file, that implements additional commands beyond read and writeconsole
- a physical or kernel implemented (tty
)terminal
command line
/prompt
- interface, where the user types a single command and hitsreturn
to executeshell
- an executable programm providing a user interface, that interprets and executes input or scripts#!/bin/sh
in a script tells you this file should be interpreted by/bin/sh
- The POSIX shell spec lists the things these interpreters MUST understand to be compliant
- While
bash
andzsh
are supersets ofsh
and therefore POSIX compliant, shells likefish
are NOT - Often
/bin/sh
is not an executable, but a symlink to/bin/bash
or others, which might not always be a good thing .
- Always try to make your scripts
/bin/sh
compliant, so they just work - link
/bin/sh
todash
run scripts faster thanbash
, but never tofish
or other NON-POSIX compliant shells - Improve the default shell configuration
Terminal
The terminal
once was an electronic device (e.g. VT100
) for input and output of text content. Today it is also a short form for terminal emulator
, which is a piece of software, that emulates this hardware device in a graphical user interface.
This means, a terminal
is responsible for the following “features”:
- Input: shortcuts, entering text, copy & paste, etc.
- Output: rendering, colors, fonts, unicode, etc.
- Extras: clipboard management, etc
So basically everything that has to do with the look & feel, rendering as well as the integration with your operating system, is your terminal
. If it does not support colors or unicode characters, it will not display these correctly.
Setting up a terminal
with modern features should be the first step before using the command line. Most POSIX compatible operating systems already have an acceptable terminal
preinstalled, but you might want to check out these alternatives:
- Alacritty - A fast, cross-platform, OpenGL terminal emulator
- ST - a simple but modern terminal implementation for X
- urxvt - a fork of the well known terminal emulator rxvt with unicode support
- Konsole - KDE’s Terminal Emulator
Console
A console
is a physical terminal
. It appears to the operating system as a (kernel-implemented) terminal. On Linux and FreeBSD, it shows up as several terminals (ttys) with the ability to switch between them with keyboard shortcuts. So there is no big difference to a terminal apart from that, even names like virtual console
, virtual terminal
and other variations basically mean the same thing.
Shell
A shell is basically a command line interpreter. Most shells also provide an interactive prompt to execute commands. Its primary purpose is to start other programs. The POSIX shell spec lists the things these interpreters MUST understand to be compliant, but not all shells follow this specs.
Interesting shells
dash
- a modern POSIX-compliant implementation of sh (also Bourne shell,/bin/sh
)bash
- a POSIX-compliant implementation with many simplifying extensionszsh
- a superset of bashfish
- Unix shell with a focus on interactivity and usability, designed to give the user features by default, rather than by configuration
dash
dash
is interesting, because it implements the POSIX shell spec
with only a minor set of extensions. This leads to the following advantages:
- Performance - roughly 4x times faster than
bash
- Low resource usage (disk space, RAM and CPU)
- Improved security (long-established, tiny, simple, many active developers)
bash
bash
is interesting, because it is the de facto standard on many distributions. It contains many extensions that simplify shell usage but also make it slower than shells with fewer extensions.
zsh
zsh
is often cited as superset of bash. It contains even more extensions and improvements, merging some features from other shells like ksh
and tcsh
.
fish
fish
is a shell with a focus on usability. What’s interesting about it, is, that it is NOT POSIX shell spec
compliant, which means, that it SHOULD NOT be linked to /bin/sh
as default shell, because it may break many scripts, especially system scripts made for /bin/sh
. This may be the reason, why fish
is often a controversial topic: Many people like it, but many don’t.
shell configuration
Most shells can be configured using a .*rc
variable in home directory, but the defaults are often not very handy or beautiful. Maybe its worth taking the time to configure your shell having the following features:
- Auto-Complete
- Syntax-Highlight
- Custom alias configs
- A beautiful themed prompt (e.g. take a look at https://github.com/romkatv/powerlevel10k for
zsh
)
Take in mind that some of these improvements may slow down shell performance, but if you choose wisely, this should not be a concern.