Linux Terminal Equipment detailed

Source: Internet
Author: User
Tags telnet program

A terminal is a character-type device that has many types, usually using TTY to refer to various types of terminal devices. TTY is the abbreviation of teletype. Teletype was one of the first terminals to appear, much like a typewriter (or a), produced by a teletype company. In the Linux system device special file directory/dev/, terminal Special device files generally have the following:

1. Serial port terminal (/DEV/TTYSN)

A serial port terminal (serial port Terminal) is a terminal device that is connected using a computer serial port. The computer regards each serial port as a character device. For a while these serial port devices are often referred to as terminal equipment, because at that time its maximum use is to connect terminals. These serial ports correspond to the device name is/dev/tts/0 (or/DEV/TTYS0),/DEV/TTS/1 (or/dev/ttys1), etc., the device number is (4,0), (4,1), respectively, corresponding to the DOS system COM1, COM2 and so on. To send data to a port, you can redirect standard output to these special file names on the command line. For example, at the command prompt, type: Echo Test >; /DEV/TTYS1 will send the word "test" to the device attached to the ttyS1 (COM2) port.

2. Pseudo Terminal (/dev/pty/)

Pseudo terminals (Pseudo Terminal) are pairs of logical terminal devices, such as/DEV/PTYP3 and/DEV/TTYP3 (or/dev/pty/m3 and/DEV/PTY/S3 in the device file system, respectively). They are not directly related to the actual physical device. If a program regards TTYP3 as a serial port device, its read/write operations to that port are reflected on the other top of the logical terminal pair (TTYP3). TTYP3 is a logical device that another program uses for read and write operations. In this way, two of programs can communicate with each other through this logical device, and one program that uses TTYP3 thinks that it is communicating with a serial port. This is much like a pipe operation between logical device pairs.

For TTYP3 (S3), any program designed to use a serial port device can use the logical device. However, for programs that use PTYP3, you need to specifically design to use the PTYP3 (M3) logical device.

For example, if someone uses a Telnet program on the Internet to connect to your computer, the Telnet program may begin to connect to the device Ptyp2 (m2) (on a pseudo terminal port). At this point a Getty program should run on the corresponding TTYP2 (S2) port. When Telnet obtains a character from the far end, the character is passed to the Getty program via M2, S2, and the Getty Program returns "Login:" String information to the network through the S2, M2, and Telnet programs. This allows the login program to communicate with the Telnet program through a "pseudo terminal". By using the appropriate software, two or more pseudo terminal devices can be connected to the same physical serial port.

Before using the device file system (device filesystem), a more complex file name naming method was used in order to obtain a large number of pseudo terminal device special files. Because there are only 16 Ttyp (TTYP0-TTYPF) of device files, in order to get more logical device pairs, we use the like Q, R, S and other characters to replace P. For example, TTYS8 and PTYS8 are a pseudo terminal device pair. However, this naming method is still used in Linux systems such as Redhat.

However, Unix98 on Linux systems do not use the above methods and use the "Pty Master" approach, such as/DEV/PTM3. Its corresponding end is automatically created into/DEV/PTS/3. This allows a Pty pseudo terminal to be provided as needed. The directory/dev/pts is a file system of type devpts and can be seen in the list of loaded file systems. Although the "file"/DEV/PTS/3 appears to be an item in the device file system, it is a completely different file system.

3. Control Terminal (/dev/tty)

If the current process has a control terminal (controlling Terminal), then/dev/tty is the device special file for the control terminal of the current process. You can use the command "Ps–ax" to see which control terminal the process is connected to. For your login Shell,/dev/tty is the terminal you are using, the device number is (5,0). Use the command "TTY" to see exactly which actual terminal device it corresponds to. The/dev/tty is somewhat similar to a connection to the actual device being used.

4. Console terminals (/dev/ttyn,/dev/console)

In a Linux system, a computer monitor is often referred to as a console terminal (console). It simulates a type of Linux terminal (Term=linux) and has some device-specific files associated with it: Tty0, Tty1, Tty2, and so on. When you log on to the console, you are using Tty1. Using the ALT+[F1-F6] combination, we can switch to Tty2, Tty3 and so on. Tty1–tty6 is called a virtual terminal, and Tty0 is an alias for the virtual terminal currently in use, and the information generated by the system is sent to the terminal. Therefore, regardless of which virtual terminal is currently in use, System information is sent to the console terminal.

You can log in to different virtual terminals so that the system can have several different sessions at the same time. Only system or Superuser root can write to/dev/tty0.

5. Other types

There are many other kinds of terminal device special files for many different character devices in the Linux system. For example,/dev/ttyin terminals for ISDN devices. Don't repeat it here.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.