TTY is the abbreviation for teletype (RPM)
A terminal is a type of character device that has many types, usually using a TTY for short-range end devices. TTY is the abbreviation for teletype. Teletype is one of the first terminal equipment, much like a telex typewriter (or ","), is produced by Teletype company. The device name is placed in the special file directory/dev/, the terminal special equipment files generally have the following kinds:
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 ports 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, 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 considers TTYP3 as a serial port device, its read/write operation on the port is reflected in the other upper (TTYP3) of the logical terminal pair. The TTYP3 is a logical device that another program uses for read and write operations. In this way, two programs can communicate with each other through this logical device, and one of the programs that uses TTYP3 thinks that it is communicating with a serial port. This is 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 a ptyp3 (m3) logical device.
For example, if someone uses the Telnet program to connect to your computer on the Internet, the Telnet program may start connecting 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 the "login:" String information to the network via S2, M2, and Telnet programs. In this way, the login program communicates 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.
Prior to the use of device filesystem, HP-UX AIX used more complex file name naming methods in order to obtain a large number of special files for pseudo-terminal devices.
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 UNIX systems, computer monitors are often referred to as console terminals (consoles). 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 is called a virtual terminal, and 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,
5. Other types
Also for many different character devices exist there are many other kinds of terminal equipment special files. For example,/dev/ttyin terminal equipment for ISDN devices. Don't repeat it here.
What does a TTY mean in Linux?