[Linux Basics] - Linux TTY framework(1)_Basic Concepts

I. Introduction

Because of the serial port, TTY is the most common type of equipment in Linux system. Students who know a little about Linux system are not unfamiliar with it. Nevertheless, I believe that few people can answer the question: What is TTY? What do the concepts such as terminal and console that we often talk about in the end mean?

This article is the first article of the Linux TTY Framework analysis article. It will introduce the basic concepts related to TTY with the above questions, and lay a solid foundation for the subsequent analysis of the TTY software framework and the analysis of the Linux serial subsystem.

2. Terminal

2.1. Basic concepts

In a computer or communication system, a terminal is an electronic (or electrical) device that is used to input data to the system (Input) or display the data received by the system (output), which is what we often call "human-computer interaction equipment" ".

The most typical example of a terminal is a teletype printer (Teletype)-a remote information transmission device based on telegram counting. Teleprinters usually consist of a keyboard, transceiver, and printing mechanism. When sending a report, press a character key to automatically send the code signal of that character to the channel (input); when receiving, it can automatically receive the code signal from the channel and print out the corresponding character (output).

2.2, Unix terminal

In the computer world, keyboards and monitors are the most commonly used terminal devices. One is used to input information to the computer, and the other is used to display the output information of the computer.

In the era of mainframe and minicomputer, terminal equipment and computer mainframe belong to the same whole. But in the PC era, the situation has changed. Unix founders Ken Thompson and Dennis Rich wanted to make Unix a multi-user system. Multi-user system means to configure a terminal for each user, and each user must have a display and a keyboard. However, all computer equipment (including monitors) were very expensive at that time, and the keyboard and the host were integrated, and there was no independent keyboard at all.

Finally they found one thing, that is the ASR33 teletypewriter. Although the teletypewriter is used to send and receive telegrams on the telegraph line, it can also be used as an interface between humans and computers, and it is inexpensive. The keyboard of the ASR33 typewriter is used to input information, and the printing paper is used to output information. So they use the ASR33 teletypewriter as the terminal, and many ASR33s are connected to the same host, and each user can enter the user name and password at the terminal to log in to the host. In this way they created the first true multi-user system Unix in computer history, and ASR33 became the first Unix terminal.

2.3, TTY equipment

From the above introduction, the first Unix terminal was a teletypewriter named ASR33, and the English word for teletypewriter was Teletype (or Teletypewritter), abbreviated as TTY. Therefore, this terminal device is also called a TTY device. This is the source of the name TTY. Of course, in the current Unix/Linux system, TTY devices have evolved into different meanings. We will introduce the evolution process later.

Note 1: After reading this, I hope readers will think carefully about the concept of "device". The teleprinter of ASR33 is a hardware device. In Unix/Linux system, this hardware device is abstracted as "TTY device" .

2.4. Serial Terminal (Serials Terminal)

Early TTY terminals (pause here specifically refers to teletypewriters) are generally connected to Unix devices through a serial port, as shown below:

Then, as you and I know, we can replace the red part (teletypewriter) above with any hardware device (such as another PC) with a keyboard, monitor, and serial port, as follows:

Therefore, for Unix/Linux systems, any device connected via a serial port can be used as a terminal device, so there is no need to pay attention to the specific terminal form. Over time, the concepts of terminal devices, TTY devices, and serial devices have gradually become mixed together and no longer distinguished. In summary, in today's Linux system:

  1. TTY devices are terminal devices, and terminal devices are TTY devices, so there is no need to distinguish;
  2. All serial devices are TTY devices;
  3. Of course, in addition to serial devices, other forms of TTY devices have also been developed, such as virtual terminal (VT), pseudo terminal (Pseudo Terminal), etc. These concepts will not be described in this article, and special articles will be used to analyze them later.

Three, the console (console)

After understanding the concepts of terminal and TTY, let's take a look at another familiar concept: console.

Back to the era when the Unix system just supported multi-users (described in section 2.2). At this time, the PC has a built-in and expensive terminal (its own keyboard, monitor, etc.). In addition, in order to support multiple users, it can be connected via a serial cable. Multiple TTY terminals (Teletype). In order to demonstrate the lofty status of the built-in terminal, people call it console.

Of course, the "state of the river" is purely a joke, but from the Chinese translation of console-console, it can be seen that the built-in terminal (console) is different from the TTY terminal in the following places:

1) The console is expensive;

2) The console (console) has more permissions than the TTY terminal, such as user creation, password change, permission assignment, etc. This is also the meaning of "control";

3) The system's running logs, error messages, etc. are usually only output to the console (console) terminal to facilitate the "control" and "management" of the administrator;

However, with the development of computer technology and the improvement of the operating system, the boundary between the console terminal and the ordinary TTY terminal has become blurred. Whatever the console can do, ordinary terminals can also do. Therefore, the console gradually degenerates, so that in the current Linux system, it only retains the third "log output" function, which is the concept of the console in the Linux TTY Framework (for details, please refer to the analysis of subsequent articles).

Guess you like

Origin blog.csdn.net/u014674293/article/details/115249231