Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

What is the difference between Terminal, Console, Shell, and Command Line?

share|improve this question
1  
(1/2) Agent Cool is mostly correct, but the definition of Console he provides is an outdated one, given this topic. His link has the correct information, if you follow it though. Read the whole definition at his link. Console is used loosely to mean a lot of similar things, but most importantly it usually refers to the LOCAL ATTACHED human input and output devices, e.g. keyboard, display, and maybe mouse. –  0xSheepdog Aug 4 at 4:48
1  
(2/2) This may seem like a pedantic point, but as a seasoned systemadmin, I will tell you it is not. When a system has a problem and appears to be completely crashed/down/offline, you should check the physical console of the system to see if it is still functioning, but simply lost network connectivity. This small detail could save or cost you a data, information processing, etc. Pedantic, yes. But important. –  0xSheepdog Aug 4 at 4:49
5  
@0xSheepdog You might want to expand these comments into a full answer (including definitions or explanations for the other terms as well), posted as such. It's not bad for a question to have multiple answers (except perhaps when they convey exactly the same information and in the same way). I'm not sure why the important practice of checking a machine locally actually relies on knowing/calling its physical human interface a console, but there is perhaps an argument that it's important for effective communication with colleagues or using documentation. (You might clarify that in your answer.) –  Eliah Kagan Aug 4 at 8:11
4  
Due to their close relation (see all the good answers) these terms are at times used synonymously, which is probably what brought you to ask this. –  Mark Aug 4 at 12:10
1  
The first three are more or less synonymous these days in the context of a modern computer OS. The difference is in their historical origin. A command line usually refers to the method for constructing a single shell command rather than the shell interface itself. –  neon_overload Aug 5 at 5:29

9 Answers 9

up vote 47 down vote accepted

The short answer is that

  • 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.

See also Why is a Virtual Terminal “virtual”, and what/why/where is the “real” Terminal?.


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. \e[Dbackward-char).
  • 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 shell in Emacs.
  • 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

share|improve this answer
1  
I'd have to disagree with you on terminal being a proper term for a terminal device file, and/or the terminal-handling code in the kernel (tty ioctls, raw/cooked, basic line editting). terminal = the stuff that handles escape codes, turns keypresses into characters, and draws on a screen (or prints on paper / tape). See my answer for more details. –  Peter Cordes Aug 5 at 10:25
1  
@PeterCordes At this level of detail, there's no distinction. POSIX defines terminal as synonymous to terminal device, in the sense of a device file. That's the Unix meaning. It does happen to be the stuff than handles escape codes, turns keypresses into characters and draws on a screen (or transmits over the network, or logs to a file, etc.). –  Gilles Aug 5 at 11:18
1  
hrm, yeah terminal does get used in that sense, too. With the assumption that there's a terminal emulator, or a serial port with a terminal appliance connected to it, on one end of the terminal device that the kernel is handling. The kernel tty handling (in cooked mode) only handles a few control codes (signals on ^c, line editting on ^u / ^? (delete). I'm trying to draw a line between the tty code and the part of Linux that implements a VT100-like terminal on a graphics card and a USB/ps2/AT keyboard. You can compile Linux without that, but not without tty. –  Peter Cordes Aug 5 at 12:41
1  
There is some symbiosis between the terminal emulator (or real terminal on a serial port), the kernel tty semantics/behaviour, and the shell or other process on the other end of the tty. I think I just half-convinced myself I'm wrong here: Consider resizing your xterm. "I resized my terminal" sounds to me more like it's talking about stty rows N cols M than just about changing the size of the X11 window. (although doing that will make xterm do the proper ioctls on the tty to update the terminal size parameters.) –  Peter Cordes Aug 5 at 12:53
2  
@PeterCordes In the kernel configuration, support for terminals can be left out (it's useful for some rare embedded systems where memory is extremely tight); it's controlled by CONFIG_TTY. Support for terminal emulators (more properly called pseudo terminals — “terminal emulator” doesn't always include telnetd, screen, expect, …) is controlled by CONFIG_UNIX98_PTYS. Support for PC text mode display and keyboard or the like is controlled by CONFIG_VT. See drivers/tty/Kconfig in the kernel source. –  Gilles Aug 5 at 16:51

A visual representation.

Terminal

enter image description here

Something you can sit down at, and work like a boss.

Console

enter image description here

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]

shell

enter image description hereenter image description here

Basically an application for running commands.

Command Line [Interface]

enter image description hereenter image description here

Basically anything you input commands into.

share|improve this answer
4  
You stole my idea - I was going to give basically the same answer. So you can have an upvote. The point being of course that while these terms are mostly synonymous these days, terms like "terminal" and "console" have their origins in older computing concepts. –  neon_overload Aug 5 at 5:27
1  
Good effort. Simple and easy –  A Umar Mukthar Aug 24 at 8:05

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

share|improve this answer
4  
"Terminal" stands for a physical text-only screen. What you say is actually "terminal emulator". –  Registered User Aug 4 at 8:30
2  
@RegisteredUser A terminal emulator is a kind of terminal. The word terminal isn't limited to physical terminals (the usual word for that is console). –  Gilles Aug 4 at 21:55
2  
This definition of command line is wrong. A command line isn't limited to an all-text display mode. –  Gilles Aug 4 at 21:57
1  
@Gilles I have grabbed it from One web-Link. You have mentioned proper answer fine. –  AgentCool Aug 6 at 4:05
5  
@AgentCool I don't question your ability to copy-paste. I question your choice of source. What you post is your responsibility, whether you wrote it or not. –  Gilles Aug 6 at 7:48

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 emacs -nw).

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 /dev/tty7, though.)

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.)

share|improve this answer
1  
Console meaning the “main” physical terminal isn't only in a kernel context. It's the same meaning in /dev/console. Console isn't particularly ambiguous — although it's occasionally used in the more general sense of terminal, that's pretty rare (rarer than terminal being used to specifically mean a console). –  Gilles Aug 5 at 11:27
1  
right, yes, echo foo | sudo tee /dev/console > /dev/null will print on the screen, if your current VT is in text mode (including framebuffer console, not just literally VGA textmode). If you booted with the console on a serial port, I think it would go there. You could say that /dev/console it the device file for whatever the kernel is treating as the system console. Nothing else in the system needs to have a notion of there being a console tty at all (except for boot-recovery stuff that starts a shell on the console TTY if the system fails to boot to multi-user mode. Usually from initrd) –  Peter Cordes Aug 5 at 12:15
1  
The xorg X server (strings /usr/bin/Xorg) doesn't use /dev/console to get hardware access. It does use /dev/tty0, and /dev/tty%d, and /dev/vc/%d, to set itself up on its own VT. I'm pretty sure Xorg would still run fine on a PC that booted with the kernel console on a serial port. And that the text-mode virtual terminals would still work. The more I consider this, the more I'm leaning towards viewing console in a kernel context as just a special terminal, selected at boot time. (Linux can actually output its console messages on multiple terminals at once, if you ask it to.) –  Peter Cordes Aug 5 at 12:32

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.

share|improve this answer

To Summarize my answer :

Shell is a program which processes commands and returns output , like bash in Linux .

Terminal is a program that run 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 I open Gnome-Terminal , a black windows appear that run Shell so i can run my commands.

Console is a special sort of terminal , it was also a Physical device . example in Linux we have virtual console which i can access them by combination of Ctrl + Alt + F1 to F7 .

Console sometimes means the keyboard and monitor physically attached to this computer.

share|improve this answer

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 a metro 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 the destination country is the terminal. It just so happens that the terminal in the airport is being used also to get people onboard (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 so 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.

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.

share|improve this answer

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.
Collocquially "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).
I don't know about unbuntu, but in some distros you can swtich between virtual terminals by pressing ctrl. + alt + F1 (thorugh F6): a leftover of those times.
Today the concept of "thin clients" goes back in this direction of centralizing massive amounts of ressources 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 C.

command line refers to the method of 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 interaface or CLI.

  1. kernel
  2. offers terminal
  3. terminal is connected via a console
  4. console runs shell
  5. commands and output are exchanged via command line (interface)
share|improve this answer
1  
Command line instructions are not understood by the kernel, but by a shell. The “core framework of instructions that the kernel understands” would be system calls. The “basic UNIX command line interface” is a shell, there's no separation between that and the “nice features”. A “terminal-emulator-window” isn't a console. –  Gilles Aug 4 at 21:59
1  
@Gilles adjusted. Obviously confused some things myself there. –  Mark Aug 5 at 5:18

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 $ or >, 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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.