Linux Basic concept summary of the terminal (Tty/pty)

Source: Internet
Author: User

In the Linux system device special file directory/dev/, terminal Special equipment files generally have the following:

1. Serial port terminal (/DEV/TTYSN)

The serial port terminal (Serial Port Terminal) is a terminal device connected using a computer serial port. The computer sees each serial port as a character device. For a while these serial port devices are often referred to as end-device, because it is used to connect the terminal at that time. The serial port corresponding 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-line prompt, type: Echo Test >/dev/ttys1 will send the word "test" to the device connected to the TtyS1 (COM2) port.

2. Pseudo Terminal (/dev/pty/)

Pseudo-terminal (Pseudo Terminal) is a paired logical terminal device (that is, the master and slave devices, the operation of Master will be reflected on the slave).

For example,/DEV/PTYP3 and/DEV/TTYP3 (or/dev/pty/m3 and/DEV/PTY/S3 in the device file system). They are not directly related to the actual physical device. If a program considers PTYP3 (master device) as a serial port device, its read/write operation on that port is reflected on the other TTYP3 (slave device) corresponding to the logical terminal. The TTYP3 is a logical device that another program uses for read and write operations. Telnet Host A is to communicate with host A's login program through "Pseudo Terminal".

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 use, the device number is (5,0). Use the command "TTY" to see which actual terminal device it corresponds to. The/dev/tty is similar to a connection to a terminal device that is actually used.

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

In Linux systems, computer monitors are often referred to as console terminals. It simulates a type of Linux terminal (Term=linux), and there are some device special files associated with it: Tty0, Tty1, Tty2, and so on. When you log in on the console, you are using Tty1. When using ALT+[F1-F6], we can switch to Tty2, Tty3, and so on. Tty1–tty6, such as virtual terminal, and Tty0 is the current use of the virtual terminal alias, the information generated by the system will be sent to the terminal (also known as Console terminal). Therefore, regardless of which virtual terminal is currently in use, the system information is sent to the console terminal. /dev/console is the console, which is the device that interacts with the operating system, and the system outputs some information directly to the console. Users are currently allowed to log in to the console only in single-user mode.

5 Virtual terminal (/dev/pts/n)

Pseudo terminal in Xwindows mode. If I use Konsole under Kubuntu, I use the virtual terminal, and I can see/DEV/PTS/1 with the TTY command.

6 Other types

The Linux system also has many other kinds of terminal equipment special files for many different character devices. For example,/dev/ttyin terminal equipment for ISDN devices. Don't repeat it here.

TTY devices include virtual consoles, serial ports, and pseudo-terminal units.

/dev/tty represents the current TTY device and enters echo "Hello" >/dev/tty in the current terminal, which is displayed directly in the current terminal.

Reference:

Http://www.linuxidc.com/Linux/2014-10/107891p2.htm (the above content is transferred from this article)

Linux Basic Concept Summary for Terminals (Tty/pty) (RPM)

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.