7

What's the difference between a console, a terminal, and a shell?

 3 years ago
source link: https://www.hanselman.com/blog/whats-the-difference-between-a-console-a-terminal-and-a-shell
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Sponsored By

I see a lot of questions that are close but the questions themselves show an underlying misunderstanding of some important terms.

  • Why would I use Windows Terminal over PowerShell?
  • I don't need WSL for bash, I use Cygwin.
  • Can I use conemu with PowerShell Core or do I need to use Windows Terminal?

Let's start with a glossary and clarify some words first.

Terminal

The word Terminal comes from terminate, indicating that it's the terminating end or "terminal" end of a communications process. You'll often hear "dumb terminal" when referring to a text-based environment where the computer you are sitting next to is just taking input and showing text while the real work happens at the other end in a mainframe or large computer.

TTY or "teletypewriter" was the first kind of terminal. Rather than a screen you'd have a literal typewriter in front of you. When you type on it, you're seeing the text on a piece of paper AND inputing that text into a computer. When that computer replies, you'll see the typewriter automatically type on the same paper.

When we refer to a Terminal in the software sense, we're referring to a literal software version of a TTY or Terminal. The Windows Terminal is that. It's really good at displaying textual output. It can take input and pass it on. But the Terminal isn't smart. It doesn't actually process your input, it doesn't look at your files or think.

Console

Folks in the mid 20th century would have a piece of furniture in their living room called a console or console cabinet. A Console in the context of computers is a console or cabinet with a screen and keyboard combined inside it. But, it's effectively a Terminal. Technically the Console is the device and the Terminal is now the software program inside the Console.

In the software world a Terminal and a Console are, for all intents, synonymous.

Shell

A shell is the program that the terminal sends user input to. The shell generates output and passes it back to the terminal for display. Here's some examples of Shells:

  • bash, fish, zsh, ksh, sh, tsch
  • PowerShell, pwsh
  • cmd, yori, 4dos, command.com

Here's an important point that should make more sense now that you have these terminals - Your choice of shell doesn't and shouldn't dictate your choice of terminal application.

Aside: WSL and WSL2 (the Windows Subsystem for Linux) are a complete local Linux (or many Linuxes) that run on Windows 10. They are full and real. WSL2 ships a real Linux kernel and runs in on Windows. Cygwin is NOT a Linux. Cygwin is a large collection of GNU and Open Source tools which provide functionality similar to Linux on Windows - but it is not Linux. It's a simulacrum. It's GNU utils compiled against Win32. It's great, but it's important for you to know what the difference is. Cygwin may let you run your bash shell scripts but it will NOT run Apache, Docker, or other real ELF-binaries and Linux apps.

Your Choice of Windows Consoles?

There are a number of shells that ship with Windows. Here's a few I'm running now. Note the "chrome" or the border and title around them? Those shells are all hosted by a the legacy Windows console you have never heard of called conhost.exe. You can go to the command prompt, type powershell, cmd, or ubuntu and any number of shells will run. Conhost does the work of input and output.

Now, forget that conhost exists, because it sucks - it's super old.

Shells that come with Windows

Pseudo Console, Pseudo Terminal, PTY, Pseudo TTY (ConPTY)

Pseudo Terminals are terminal emulators or software interfaces that emulate terminals. They pretend to be terminals like the ones above. *Nix systems have long had a pseudo-terminal (PTY) infrastructure and now Windows as a pseudoconsole (ConPTY) as well.

Window's new ConPTY interface is the future of consoles and terminals on Windows. If you choose a 3rd party (non-built-in) console applications for Windows, make sure it supports ConPTY and it'll be a better experience than some of the older consoles that use screen scraping or other hacks.

image

Back to your choice of Windows Consoles

Remembering there's a lot of shells you can use in Windows, there's a lot of 3rd party consoles you can use if you don't like conhost.exe (and you shouldn't).

All of these Terminals support ALL the shells above and any shells I've missed. Because a shell isn't a terminal. Pick the one that makes you happy. I use PowerShell Core and Ubuntu in WSL2 in the Windows Terminal.

Windows Terminal

Hope this helps clear things up.


Sponsor: Suffering from a lack of clarity around software bugs? Give your customers the experience they deserve and expect with error monitoring from Raygun.com. Installs in minutes, try it today!


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK