What is the difference between Terminal, Console, Shell, and Command Line?
- terminal = text input/output environment
- console = physical terminal
- shell = command line interpreter
Console and terminal are closely related. Originally, they meant a piece of equipment through which you could interact with a computer: in the early days of unix, that meant a teleprinter-style device resembling a typewriter, sometimes called a teletypewriter, or “tty” in shorthand. The name “terminal” came from the electronic point of view, and the name “console” from the furniture point of view. Very early in unix history, electronic keyboards and displays became the norm for terminals.
In unix terminology, a terminal is a particular kind of device file which implements a number of additional commands (ioctls) beyond read and write. Some terminals are provided by the kernel on behalf of a hardware device, for example with the input coming from the keyboard and the output going to a text mode screen, or with the input and output transmitted over a serial line. Other terminals, sometimes called pseudo-terminals or pseudo-ttys, are provided (through a thin kernel layer) by programs called terminal emulators. Some types of terminal emulators include:
- GUI applications running in the X Window System: Xterm, Gnome Terminal, Konsole, Terminator, etc.
- Screen and tmux, which provides a layer of isolation between a program and another terminal
- Ssh, which connects a terminal on one machine with programs on another machine
- Expect, for scripting terminal interactions
The word terminal can also have a more traditional meaning of a device through which one interacts with a computer, typically with a keyboard and display. For example an X terminal is a kind of thin client, a special-purpose computer whose only purpose is to drive a keyboard, display, mouse and occasionally other human interaction peripherals, with the actual applications running on another, more powerful computer.
A console is generally a terminal in the physical sense that is by some definition the primary terminal directly connected to a machine. The console appears to the operating system as a (kernel-implemented) terminals. On some systems, such as Linux and FreeBSD, the console appears as several terminals (ttys) (special key combinations switch between these terminals); just to confuse matters, the name given to each particular terminal can be “console”, ”virtual console”, ”virtual terminal”, and other variations.
Command line [interface]
A command line is an interface where the user types a command (which is expressed as a sequence of characters — typically a command name followed by some parameters) and presses the Return key to execute that command.
A shell is the primary interface that users see when they log in, whose primary purpose is to start other programs. (I don't know whether the original metaphor is that the shell is the home environment for the user, or that the shell is what other programs are running in.)
In unix circles, shell has specialized to mean a command-line shell, centered around entering the name of the application one wants to start, followed by the names of files or other objects that the application should act on, and pressing the Enter key. Other types of environments (with the notable recent exception of Gnome Shell) usually don't use the word “shell”; for example, window systems involve “window managers” and “desktop environments”, not a “shell”.
There are many different unix shells. Ubuntu's default shell is Bash (like most other Linux distributions). Popular alternatives include zsh (which emphasizes power and customizability) and fish (which emphasizes simplicity).
Command-line shells include flow control constructs to combine commands. In addition to typing commands at an interactive prompt, users can write scripts. The most common shells have a common syntax based on the Bourne_shell. When discussing “shell programming”, the shell is almost always implied to be a Bourne-style shell. Some shells that are often used for scripting but lack advanced interactive features include the Korn shell (ksh) and many ash variants. Pretty much any Unix-like system has a Bourne-style shell installed as
/bin/sh, usually ash, ksh or bash. On Ubuntu,
/bin/sh is Dash, an ash variant (chosen because it is faster and uses less memory than bash).
In unix system administration, a user's shell is the program that is invoked when they log in. Normal user accounts have a command-line shell, but users with restricted access may have a restricted shell or some other specific command (e.g. for file-transfer-only accounts).
The division of labor between the terminal and the shell is not completely obvious. Here are their main tasks.
- Input: the terminal converts keys into control sequences (e.g. Left →
\e[D). The shell converts control sequences into commands (e.g.
- Line edition, input history and completion are provided by the shell.
- The terminal may provide its own line edition, history and completion instead, and only send a line to the shell when it's ready to be executed. The only common terminal that operates in this way is
M-x shellin Emacs.
- The terminal may provide its own line edition, history and completion instead, and only send a line to the shell when it's ready to be executed. The only common terminal that operates in this way is
- Output: the shell emits instructions such as “display
foo”, “switch the foreground color to green”, “move the cursor to the next line”, etc. The terminal acts on these instructions.
- The prompt is purely a shell concept.
- The shell never sees the output of the commands it runs (unless redirected). Output history (scrollback) is purely a terminal concept.
- Inter-application copy-paste is provided by the terminal (usually with the mouse or key sequences such as Ctrl+Shift+V or Shift+Insert). The shell may have its own internal copy-paste mechanism as well (e.g. Meta+W and Ctrl+Y).
- Job control (launching programs in the background and managing them) is mostly performed by the shell. However, it's the terminal that handles key combinations like Ctrl+C to kill the foreground job and Ctrl+Z to suspend it.
Recycled from Unix & Linux
A visual representation.
Something you can sit down at, and work like a boss.
Some hardware that does a bunch of stuff.
Another example of a console, would be a video game console such as a Super Nintendo [where you can play Actraiser]
Basically an application for running commands.
Command Line [Interface]
Basically anything you input commands into.
From the Linux Information Project:
Terminal : Technically , A terminal window, also referred to as a terminal emulator, is a text-only window in a graphical user interface (GUI) that emulates a console.
In Our words A GUI Application , from where we can access an user's console.
Console: an instrument panel containing the controls for a computer
Shell :A shell is a program that provides the traditional, text-only user interface for Linux and other Unix-like operating systems
Command-Line : A command line is the space to the right of the command prompt on an all-text display mode on a computer monitor (usually a CRT or LCD panel) in which a user enters commands and data
The Shell is a program which processes commands and returns output, like Bash in Linux.
A Terminal is a program that runs a Shell. In the past it was a physical device (before terminals were monitors with keyboards, they were teletypes) and then its concept was transferred into software, like GNOME Terminal.
So when I open GNOME Terminal, a black window that runs a Shell appears so I can run my commands.
A Console is a special sort of terminal. It was also a physical device. For example in Linux we have virtual consoles, which we can access by a combination of Ctrl+Alt+F1 to F7.
Console sometimes means the keyboard and monitor physically attached to this computer.
The answers here seem very good. However they are too dry and technical for my taste so I'll give a take.
Terminal is the end of something - where it terminates. For example if you take the subway in some city, the station where you get down is your terminal. Or in an airport the place where people come out when they reach their destination country is considered the terminal. The reason the terminal in the airport is nowadays both the place you get people onboard and the place you get them off the plane is for obvious economic reasons.
A computer's purpose is to get data, do something with it, and spit out the result. Thus the terminal is any device from where you can get the result of the computation (a screen for example). It just happened that in the first computers you usually had the input (keyboard) and output (screen) as a single device. Because of that, nowadays terminals are considered any input/output devices. A mouse, keyboard, screen, camera, they are all terminals.
Shell is an OS thing. On a computer you have the kernel which on Ubuntu for example is the Linux part. Now since the kernel is really low-level a shell is provided - a program that let's the user interact with the kernel in an easy way. That's what BASH is for example.
Console is (from a dictionary)
a flat surface that contains the controls for a machine, for a piece of electrical equipment, etc.
That's why in music industry the board with all the knobs, or in a space shuttle the command table, they are all considered consoles. Super Nintendo and PS2 are also called consoles historically since the first such entertainment devices looked like boxes with a bunch of buttons on them.
Command line is just an interface - the opposite of GUI. Namely there are two types of interfaces on a computer; CLI (command line interface) and GUI (graphical user interface). The main difference is that the first one gets input from the keyboard while the second gets input from the mouse.
These terms often go together, so people use one of the terms to refer to the collection. (i.e. it's usually obvious from context that they mean a terminal window providing an interface to a command line shell).
To keep this from getting to long-winded, I'm just going to say xterm as a stand-in for XTerm / Gnome Terminal / Konsole / mrxvt / etc / etc. Same for bash.
Console has multiple other specific meanings, so leave that out for now.
Terminal: Something that provides human interaction with programs through a bidirectional stream of ASCII / UTF8 / other characters, usually with VT100 or similar escape code processing. (E.g. backspace, delete, arrow keys, etc. generate escape codes. Programs can print escape codes to move the cursor around the terminal screen, switch to bold text, and/or color, clear or scroll the screen, etc.) In the old days, this was often a dedicated appliance with a screen and keyboard and a serial port. Now, it's usually a program like xterm.
There are device files for programs to read/write from/to terminals, and virtual terminals also have the other side accessible as a device file. This is where xterm writes your input so bash can read it.
Every terminal, including virtual ones, provides basic line editing when it's in cooked (as opposed to raw) mode. This is handled by kernel code. It's bash that provides the line editing that you can do with the arrow keys. (Try running
cat and typing if you want to see what the basic kernel-provided line editing is like. Backspace works, and a couple other things as per your stty settings.)
Even though there is a lot of kernel code behind the terminal devices, it would be refered to as terminal-handling code, not as a terminal itself.
Edit: Gilles has convinced me that referring to a tty as a terminal is proper usage. Terminal Emulators, and interactive programs that run connected to a terminal, are all dependent on the terminal semantics implemented by the kernel. (Most of this behaviour is standardised by POSIX, and is the same across Linux/*BSD/other Unix.) A full-screen text editor depends on the behaviour of Unix tty stuff as well as the cursor-movement escape-code handling, and many other features, of the terminal emulator.
However, a physical VT100 with a screen, keyboard, and serial port is an instance of a terminal. It doesn't require a Unix kernel on the other end of its serial port to be complete. Something completely different could be sending it escape codes and ASCII text, and receiving the same from it. It would just be a VT100, though, not a Unix terminal. A terminal emulator plus the Unix tty semantics make up the full package of a Unix terminal that a program like bash normally runs on.
Command line is a style of user interface, where you type something, then press return to make something happen. It's also used as a shorthand for a command-line shell, like bash or MS-DOS, but you can also say “it's a command line tool” about something like fdisk. Considering only programs that use a terminal for their UI, the two main families are command line and full-screen text (e.g. an editor like vi or
Command line programs that normally run on terminals almost always still work with their input and output redirected to files, but terminal-based full-screen programs like editors or email clients are interactive-only, and wouldn't work.
A shell is a program for starting other programs. In a Unix context, it's common to mean command-line shell (i.e. Bourne shell or C shell equivalent). Unix shells can also read their input from files, i.e. shell scripts. They are full programming languages, with variables, loops, and conditionals, and many programs are written in bash (or with only the
/bin/sh POSIX shell features, for more portability). It's also easily possible to write a quick
for i in *.something; do some_program "$i";done in an interactive shell.
Putting it all together, a shell like bash (or whatever program you started by running a shell command) will receive characters from the
/dev/pts/N terminal device after xterm writes your input into its side of the pseudo-terminal. If you run
cat, then hit
^c, the kernel tty code will act on the
^c and send a
SIGINT to the foreground process on that terminal. (Note the usage of terminal in this context to mean the Unix tty, not a terminal emulator or something hooked up to a serial port.) This happens because the shell puts the terminal into "cooked" mode before starting any program, which means the kernel acts on some control-sequences. (The tty code still has nothing to do with handling VT100 escape codes, just a few low-ASCII control codes.) If instead of an xterm, you are using the Linux console text terminal, then the kernel IS doing the VT100 emulation, and handling all that stuff. Linux can be compiled without virtual console text terminal support, but not without tty support.
Console is sometimes used as a synonym for terminal (KDE even has a terminal emulator called Konsole).
As 0xSheepdog points out, it also has another meaning: locally attached human-interaction hardware.
In a kernel context, console has another specific meaning: it's the terminal where boot messages are written. This can be a serial port. Normally, of course, it's the text console implemented by the kernel on top of the drivers for graphics hardware and USB/ps2/AT keyboards. If you boot Linux with
console=tty0 console=ttyS0,115200n8 on the command line, you'll get kernel messages on your screen AND on the serial port.
Linux implements virtual consoles (
/dev/tty1 to N). You can swap which one your physical screen/keyboard are controlling with Ctrl+Alt+FN. Typical Linux distros create 6, and start
getty on all of them, so even if you can't or don't want to start X11, you can log in 6 times and flip between a command, a man page, and whatever else, without running a program like screen. Linux (the kernel) includes a VT100-style terminal emulator to provide a terminal interface through your screen and keyboard on the virtual consoles.
The standard 6 virtual terminals with login prompts is why Ctrl+Alt+F7 gets you back to your X11 session: the X server grabs the next available virtual console. (The X server opens
/dev/input/... directly, rather than getting your keypresses from
So "swap to a text console" means to press Ctrl+Alt+F1 and use that terminal. Back when computers were slow and didn't have much RAM, some people spent much of their time on the text consoles, since they were fast, you could set a nice font, and even change the terminal size to have smaller characters, but have more on screen at once. Alt+Left and Alt+Right swap to prev/next console. (X11 disables this for its console, of course, leaving only the Ctrl+Alt+FN combo.)
So console is the only one of these terms that doesn't have a single well-defined technical meaning. It has a couple different ones. (Depending on how you feel about terminal proper vs. terminal plus tty handling, you could say that terminal also has multiple meanings.)
I think that back in the early days of time-sharing computers, every user had a terminal (when they could get one!), but only the system operators had a console. The console could be used for tasks like rebooting the machine or getting system diagnostics that weren't possible from user terminals. The console was in the machine room, an intrinsic part of the computer, whereas the terminals could be remote. The console would also include hardware lights and switches, not just text input and output.
I would say that the command line is an area where a user can type a command, whereas the shell is the program that interprets/obeys that command. The term "shell" is very particular to Unix derivatives; "command-line" is more in the Windows/DOS tradition. The equivalent on mainframes is usually called a "job control language".
Clearly, these original distinctions have become blurred over time as technology changes.
Trying user-centric short answer:
command line - the line where you enter commands. Usually it used to tell that you need to run something in text mode window (command line interface) provided by your operating system.
shell - the actual program run by operating system to process stuff you enter into
command line. Hence the name - user-friendly shell for non-friendly OS core. It provides command prompt, such as
>, runs its own commands and apps. You always work through the
shell program and never operate with console or terminal directly.
console - is a window where your text mode programs are running. This window processes key presses, knows it is width and height. Can be fullscreen.
terminal - is some device with display for humans that accepts input stream of characters and shows them. There is no feedback to user about height or width (only hacks) or keyboard keypresses - only chars are travelling to it. Terminal processes special sequences in this stream to make things colored, clean up the screen and do other nasty things. Terminals are flaky, because it is easy to mess things if the file you are piping to output contains that special sequences. They are popular in networking and device debug interfaces, because you just need a single stream for sending output and control the output device and you can just
tap into conversation without the need to initialize or create a window.
serial console - is a console that processes input stream like a terminal.
This is a vague topic, because the terms are very ambiguous. I strongly recommend reading the links I've provided throughout this answer, which are also my sources for this answer.
A shell is the layer above the kernel:
- It interprets the commands entered by the user, and processes them. The shell has access to the kernel, unlike users. Users can only access the kernel through entering commands using a shell, and by using processes (i.e. running programs). Programs use system calls to access kernel functionality. All system calls together form the system API.
- Examples of shells are given in the second terminal definition.
A terminal has many meanings:
- (1) A text terminal. This is the combination of a display monitor and a keyboard. A cable connected the terminal to the computer (often indirectly). It was called a terminal since it was located at the terminal end of this cable. These terminals were usually physically separated from the computer, because back in the days many terminals were connected to a single mainframe/computer, so multiple users could have access to the computer at the same time.
- (2) A terminal window a.k.a. terminal emulator. In Linux, a terminal window is the emulation of a console, contained in a GUI window. It is the CLI you type your text in, and this input is read by the shell you're using. There are many types of shells (e.g. bash, dash, ksh88) and terminals (e.g. konsole, gnome).
- (3) For an explanation on pseudo terminals, view this. It's a pair of two 'device files' used for communication between a process and a terminal emulator.
A console has many meanings:
- (1) an instrument panel containing the controls for a computer.
- (2) A System console a.k.a. computer console. This is the combination of the display monitor and a keyboard connected to a computer. This is synonymous with what we call a 'text terminal'. Sometimes also other user-input peripherals such as a mouse is part of a console.
- (3) A command-line interface that covers the full screen. This is in contrast with a terminal window, which is a GUI with an X at the right top corner to close it. These are the two display modes for CLI (command-line interfaces) in Unix-like systems. Similarly to a terminal window, the console can run many shells as well.
Often, operating systems allow you to run multiple consoles on a physical console (console definition 2). These are called virtual consoles a.k.a. virtual terminals, and can be accessed through ctrl + alt + Fx combinations. For example, if you want to open the 3rd virtual console, you use the combination ctrl + alt + F3.
Consoles (definition 3) might appear to you as an anachronism, but experts should be comfortable using them, since there are many OSes that do not support GUI's. Also, if a GUI stops responding, the console may still work.
Most terminals nowadays are strictly speaking terminal emulators.
It is a type of role in the workings of a UNIX-like system and at the same time the basic interface offered by the systems. In fact everything, including the GUI builds on top of it.
Colloquially "terminal" may also refer to end-points in a computer network with a star-topography.
Console refers to the (hardware) interfaces for the terminals. I.e. there are serial consoles and nowadays mostly virtual ones.
The window colloquially referred to as "console"-window is a shell, connected to a terminal of the system, via a virtual console.
Back in the day when computers were expensive a facility might have had one actual computer and several terminals connecting to it, via serial cables ("serial console"). The OS, operations, etc. were carried out on the physical Computer, input and output happened on the console(s).
You can switch between virtual terminals by pressing CTRL+ALT+F1(through to F6): a leftover of those times.
Today the concept of "thin clients" goes back in this direction of centralizing massive amounts of resources and providing just enough hardware to provide a state of the art interface at the actual workplace.
shell is the "engine" that you see in the terminal. It provides interop with the system itself and adds nice features like auto-complete, variables etc..
It translates back and forth between the actual OS / kernel which uses system calls and you. System calls w/o shell are a bit like coding
assembler and a shell at least gives you
command line refers to the method of exchanging input and output via a text-window. Strictly speaking the line in which you type is the (current) command line. The method in general is more correctly referred to as command line interface or CLI.
- offers terminal
- terminal is connected via a console
- console runs shell
- commands and output are exchanged via command line (interface)