英文链接:https://fossbytes.com/difference-between-shell-console-terminal/

Linux系统有几个相近但不同的概念:shell、terminal、console、tty、pts,其中shell、terminal和console是经常接触,但很难说出区别的三个概念。这篇英文很好的解释了这几个概念的来源,以及相互之间的区别。

以下是文章原文:


Short Bytes: What sounds like what could be a really bad joke, or a really good one if you’re into that humor, is actually an honest question. The shell, console, and terminal are all very dated concepts that we still use today, in albeit modified forms. Did you know that a terminal used to be a physical monitor and keyboard and a console was a port with a low-level connection to the operating system? But where does that leave the shell?

Introduction

As technology progresses, lines get blurred between objects and concepts that were previously very distinct. Words can be colloquialized to share the same meaning when they once had their own. Sometimes multiple devices can be melted down into a single box without any sign of their separate technological lineage. Something similar happened to the shell, the console, and the terminal.

For many years now, the wireless router has been the backbone of internet connectivity in most homes and many small offices. But many people fail to realize (except for the technically astute among you) that the device is actually made up of several devices that used to be independent of one another and quite well-defined. A typical wireless router, even the cheapest of cheap, contains a wireless access point, ethernet switch, router, stateful firewall, DNS server, DHCP server, QoS engine, and sometimes many more features (such as a DSL/coax modem). As a result, the technical layperson might refer to this device as “the wireless,” a modem, a router, or simply “the internet box.” All of which fail to encapsulate the whole story, and that’s only one example (and not even what this article is about).

Shell, Terminal, and Console — How are they different?

Anyone who has tried their hand at an operating system outside the realm of Microsoft and Apple in any serious capacity has undoubtedly come into contact with the command line interface. What do you call it? The shell? The console? The terminal? Does it matter? They all mean the same thing, right? The answer to that is yes and no. Just like the wireless router, these used to be (and technically still are) different parts of the same whole, despite the words sharing their meanings.

What is a Terminal?

To understand what a terminal is, we have to go back to the mainframe days. Mainframes were computers with many users. They were common in large businesses and on college and university campuses. But when you have dozens of people that want to use one computer at the same time, how do you make them share it? In today’s words, we would give them each a monitor, a keyboard, and a mouse. In the era of the mainframe, terminals were used. A ‘terminal’, as defined by dictionaries, is either the end of something or a point of contact, sometimes both. Mainframes had terminal stations equipped with a display and keyboard scattered around the premise. They were endpoints where users could access the mainframe.

What is a Console?

Today, consoles can be entirely in software, but that wasn’t always the case. Consoles go hand in hand with terminals. With respect to a mainframe, a console was both the port and the digital connection to the mainframe operating system from the terminal. A broader definition of a console is a desk or dashboard like interface from which a system is controlled and/or monitored. The terminal would be physically connected to the console port on the mainframe so that the user could control the mainframe digitally. On a Linux system you can press <ctrl> + <alt> + <F1 | F2 | F3 | …> to reach the different software consoles. Many systems still have serial-based console ports for management, such as professional network equipment.

What is a Shell?

The shell has a funny name, but only because the ‘kernel’ of an operating system is an even funnier name. A shell is the piece of material that wraps around a kernel. In computers, there is no difference (except that the shell and kernel are software). The shell is the command line interface you interact with. Examples of shells are BASH, CSH, and ZSH. The shell takes hand-typed commands and tells the operating system to execute them, or can take scripts and interpret logic within them in addition to instructing the operating system to execute the commands contained in the script.

Shell vs Console vs Terminal

So, what is the actual difference between shell, consol and terminal? The terminal connects to the console where the shell is presented. That’s simple enough, right? There are some other pieces of terminology that might be useful, though. A TTY is a teletypewriter. It is essentially the equivalent of the console port but is often virtualized in software. If you jump to a different virtual console on your Linux machine using the above keyboard combination and login in, you can see the multiple consoles with logged in users by running the who command. Then there are PTS devices which are Pseudo Terminal Slaves, a virtual device of sorts. They are a form of TTY, but one that is emulated to allow a TTY connection over a network or some other means. SSH and Telnet are good examples of programs that use PTS devices.

Over time, many words in technology have fallen victim to over generalization that tends to hide a rich and adventurous history of innovation and evolution. Considering this, it might be worthwhile to curb our adoption of reductive vernacular in an effort to preserve this history and possibly allow for a more technically informed layperson in the future.