Linux terminal, console, tty, pty, etc.

Source: Internet
Author: User

Reference: http://news.newhua.com/news1/program_language/2010/623/10623141048745773199BCF0CFH6AKB9930IGCFKHBH4IBE65IDFI07F.html? Lt = common

Basic concepts:

1> tty):

Tty is derived fromElepes,It was originally referred to as a telex typewriter, which was used to read and send information through the printer keyboard through a serial line. later it was replaced by the keyboard and display, so it is now more appropriate to call the terminal.

,

2> pty (Pseudo Terminal, virtual terminal):

But if we remotely telnet to the host or use xterm, do we still need a terminal to interact? Yes, this is the virtual terminal pty (pseudo-tty)

3> pts/ptmx (combining pts/ptmx to implement pty ):

Pts (pseudo-terminal slave) is the implementation method of pty. It is used with ptmx (pseudo-terminal master) to implement pty.

In the special file directory/dev/of a Linux system device, there are generally the following types of special device files on the terminal:

1. Serial Port Terminal (/dev/ttySn)

The Serial Port Terminal (Serial Port Terminal) is a Terminal device connected by a computer Serial Port.The computer regards each serial port as a character device. For some time, these serial port devices are usually called terminal devices, because at that time they were used to connect terminals.The device names corresponding to these serial ports are/dev/tts/0 (or/dev/ttyS0),/dev/tts/1 (or/dev/ttyS1), etc, the device numbers are (), (), and so on, respectively, corresponding to COM1 and COM2 in the DOS system.. For example, if you type echo test>/dev/ttyS1 at the command line prompt, the word "test" is sent to the device connected to the ttyS1 (COM2) port.

2. Pseudo Terminal (/dev/pty /)

The Pseudo Terminal is a pair of logical Terminal devices (namely, the master and slave devices, and the operations on the 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 physical devices.Ttyp3 is the logical device used by another program for read/write operations. Telnet host A communicates with the logon program of host A through A Pseudo Terminal.

3. control terminal (/dev/tty)

If the current process has),/dev/tty is the device special file of the control terminal of the current process.. You can run the "ps-ax" command to check which control terminal the process is connected.For the shell you log on to,/dev/tty is the terminal you are using, and the device number is (5, 0 ).Run the "tty" command to check which actual terminal device it corresponds. /Dev/tty is similar to a connection to the actually used terminal device.

4,

). It simulates a Linux terminal (TERM = Linux ),In addition, some special device files are associated with these files: tty0, tty1, and tty2..When you log on to the console, tty1 is used.. With Alt + [F1-F6] keys, we can switch to tty2, tty3 and so on.Tty1-tty6 is called virtual terminal, and tty0 is an alias of the current virtual terminalThe information generated by the system will be sent to the terminal (also called the console terminal ). Therefore, no matter which virtual terminal is being used, the system information will be sent to the console terminal. /Dev/console refers to the console, which is a device that interacts with the operating system. The system directly outputs some information to the console. Currently.

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

For example, if I use konsole in Kubuntu, It is a virtual terminal. Run the tty command to view/dev/pts/1.

6. Other Types

In Linux, there are many other types of special files on terminal devices for many different character devices. For example,/dev/ttyIn terminal devices for ISDN devices. I will not go into details here.

Tty devices include:

Virtual console, serial port, and Pseudo Terminal devices.

/Dev/tty indicates the current tty device. Input echo "hello">/dev/tty in the current terminal, which will be directly displayed on the current terminal.

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.