Concepts and differences of TTY, Pty, and PTS for Linux systems

Source: Internet
Author: User

concepts and differences of TTY, Pty, and PTS for Linux systems

    1. TTY (collectively referred to as terminal equipment):
      The word "TTY" originates from teletypes, or teletypewriters, which originally refers to a telex typewriter, which is used to read and send information through a printer keyboard through a serial line, which is later replaced by a keyboard and a display, so it is now more appropriate to call the terminal.
      A terminal is a type of character device that has many types, usually using a TTY for short-range end devices.

TTY means seven alt+crtl+f1~f7.

TTY1-TTY6 represents the text interface, you can switch with Ctrl+alt+f1-f6, +F7 is to switch back to the graphical interface.

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, etc., is called a virtual terminal,
The Tty0 is an alias of the virtual terminal that is currently used, and the information generated by the system is sent to the terminal.
Therefore, regardless of which virtual terminal is currently in use, the system information is sent to the console terminal.
You can log in to a different virtual terminal, which allows the system to have several different session periods at the same time.
Only the system or Superuser root can write to/dev/tty0.

    1. Pty (Virtual Terminal):
      But does it require a terminal interaction if we telnet to the host or use xterm remotely? Yes, this is Virtual Terminal pty (Pseudo-tty).

    2. PTS/PTMX (PTS/PTMX is used in combination to achieve pty): Pseudo-terminal in Xwindows mode.
      PTS (pseudo-terminal Slave) is an implementation of Pty, implemented Pseudo-terminal with PTMX (Pty Master).
      That's what man says: Ptmx and pts-pseudo-terminal master and Slave,
      PTS is the so-called pseudo-terminal or virtual terminal, the specific manifestation is that you open a terminal, this terminal is called pts/0, if you open a terminal, the new terminal is called PTS/1.

For example, with the WHO command to query the current logged-in user, you can see each user's TTY device (simple is the user Input command and display information device, such as terminal), the following is the display on my machine:
[email protected] ~]# who
XJB tty1 2018-02-18 03:01 (: 0)
XJB pts/0 2018-02-18 03:02 (: 0.0)
Root PTS/1 2018-02-18 03:06 (192.168.31.1)
Root PTS/2 2018-02-18 03:07 (192.168.31.1)
Root PTS/3 2018-02-18 03:07 (192.168.31.1)
Root PTS/4 2018-02-18 03:07 (192.168.31.1)
[Email protected] ~]#

There is a tty1 is a graphical interface, the current login is GNOME, is a graphical interface.

(: 0.0) indicates that the server is logged on

Send a message between two pts

[[email protected] ~]# TTY
/dev/pts/3
[Email protected] ~]# echo "Hey Binn. How is You? ">/dev/pts/2

[[email protected] ~]# TTY
/dev/pts/2
[Email protected] ~]# Hey Binn. How is it?

Funny thing, just send it a red font message.
Please refer to the ANSI control code for color code details.
[Email protected] ~]# echo-e "\033[31mhey. binn.\033[0m ">/DEV/PTS/2

Concepts and differences of TTY, Pty, and PTS for Linux systems

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.