Linux foundation of the terminal, console, tty, pty concepts such as Introduction

basic concepts:

1> tty (collectively referred to as terminal equipment):

The word from teletypes tty, or teletypewriters, refers to the original teletype information is read and send the printer serial line via the keyboard things, something which later was substituted by a keyboard and a display, it is now appropriate calling terminal.

Character is a terminal device, which has many types, commonly referred to using various types of terminals tty device.

2> pty (pseudo terminal, virtual terminal):

But do not you need an interactive terminal What if we telnet to a remote host or use xterm? Yes, this is the virtual terminal pty (pseudo-tty)

3> pts / ptmx (pts / ptmx used in combination, so as to realize pty):

pts (pseudo-terminal slave) method to achieve the pty with ptmx (pseudo-terminal master) achieved with the use pty.

Linux system in the device special file directory under / dev / terminal special device files generally have the following:

1, a serial port terminal (/ dev / ttySn)

Serial Port Terminal (Serial Port Terminal) using a terminal device connected to a computer serial port. Each serial port of the computer are seen as a character device. There was a time these devices are often referred to as serial port terminal device, because then its greatest use is used to connect terminals. The serial port is corresponding to the device name / dev / tts / 0 (or / dev / ttyS0), / dev / tts / 1 (or / dev / ttyS1) and the like, the device number, respectively (4,0), ( 4,1), etc., respectively corresponding to the DOS system, COM1, COM2 and the like. To send data to a port, on the command line to standard output is redirected to these special file name. For example, at the command prompt, type: echo test> / dev / ttyS1 will word "test" is sent to the connected ttyS1 (COM2) port device.

2, the pseudo-terminal (/ dev / pty /)

Pseudo-terminal (Pseudo Terminal) paired logical terminal device (i.e., master and slave devices, the operation will be reflected on the master to the slave).

E.g. / dev / ptyp3 and / dev / ttyp3 (or device file system are / dev / pty / m3, and / dev / pty / s3). They are not directly related to the actual physical device. If a program the ptyp3 (master apparatus) is regarded as a serial port device, then it is the read port / write operations will be reflected in the other terminal device corresponding to the logical ttyp3 the above (slave devices). While another program is ttyp3 logic device for read and write operations. A host telnet login procedure is performed by communicating "pseudo-terminal" and the host A.

3, the control terminal (/ dev / tty)

Control means capable of controlling a terminal, the terminal controller sets of sets of equipment, or device.

If the current process has a control terminal (Controlling Terminal), then the / dev / tty is the special device file control terminal of the current process. You can use the command "ps -ax" to see the process and which is connected to the control terminal. For your login shell, / dev / tty is the terminal you are using, the device number is (5,0). Use the command "tty" which may see it actually corresponds to a specific terminal device. / Dev / tty somewhat similar to a coupling terminal device actually used.

4, console terminal (/ dev / ttyn, / dev / console)

In the Linux system, the computer display is typically referred to as the console terminal (Console). It emulates a terminal (TERM = Linux) for Linux type, and there are some special device files associated with it: tty0, tty1, tty2 like. When you log on the console, using tty1. Use Alt + [F1-F6] key combination, we can switch to above tty2, tty3 like to go. tty1-tty6 the like called a virtual terminal, and the information tty0 is currently used an alias virtual terminal, generated by the system will be sent to the terminal (in this case also known as console terminal). Therefore, regardless of which virtual terminal is currently in use, the system information will be sent to the console terminal. / Dev / console console i.e., to interact with the operating system of the device, some of the information will be directly output to the console. At present, only in single-user mode, it allows the user to log into the console.

5, virtual terminal (/ dev / pts / n)

Xwindows mode in the pseudo-terminal (a graphical interface) As I konsole, the virtual terminal is to use in Kubuntu, can be seen with the tty command / dev / pts / 1.

6, other types

Linux system, there are many different characters for many other types of equipment terminal device special file. For example, ISDN equipment / dev / ttyIn terminal equipment. Not repeat them here.

tty devices include:

Virtual consoles, serial ports, and pseudo-terminal device.

/ Dev / tty tty device representative of the current, the current input terminal echo "hello"> / dev / tty, are displayed directly in the current terminal

Well, today's share to end here, if you need more technical articles can be accessed Marco education official website!

Guess you like

Origin www.cnblogs.com/woshijiuke/p/11800473.html