Terminal types for Linux

Source: Internet
Author: User
Tags documentation telnet program

Terminal is a very important peripheral, the people who used the terminal equipment know that if the device type is wrong, there will be random characters, can also be used simulation terminal software such as Netterm test, Linux terminal information under/usr/share/terminfo, In the subdirectory of this directory v there are a lot of such as vt100,vt102,vt200, you can see that.

Case:
If the SSH terminal is executed first:
Term=linux
To use the top command.


To view the terminal type name of the terminal emulation, view the term variable:
# Export | grep term
Declare-x term= "Xterm"

The current term value can be viewed via env


What is Q:/dev/console?

A:/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.

What is Q:/dev/tty?

A:tty devices include virtual consoles, serial ports, and pseudo-terminal units. /dev/tty represents the current TTY device, in the current terminal input: echo "Hello" >/dev/tty, will be displayed directly in the current terminal.

What is q:/dev/ttys*?

A:/dev/ttys* is a serial terminal device.

What is q:/dev/pty*?

A:/dev/pty* is pseudo terminal, the so-called pseudo-terminal is a logical end-device, mostly used to simulate terminal program. For example, the terminal we opened under X window, and the way we log in to a Linux host using Telnet or SSH in Windows, are using the Pty device, which is exactly the Pty from the device (/dev/pts/*).

What is q:/dev/tty0 and/dev/tty1-/dev/tty63? What's the difference between them?

A:/dev/tty0 represents the current Virtual console, while/dev/tty1 represents the first virtual console, for example: When switching with ALT+F2, the system's Virtual Console is/dev/tty2, and the current console points to/dev/tty2.

Q: How do I determine which terminal (or console) is currently located?

A: Use the TTY command to determine the current terminal or console.

is q:/dev/console a symbolic link to/dev/tty0?

A: Most of the current text says/dev/console is a link to/dev/tty0 (including "Linux kernel source Scenario analysis"), but that's not true. According to the kernel documentation, before 2.1.71, the/dev/console can be linked to/dev/tty0 or other Ttyn depending on the settings of the system, which is completely controlled by the kernel after version 2.1.71. Currently, only/dev/console can be logged in in single-user mode, which can be confirmed by entering the TTY command in single-user mode.

What is the difference between q:/dev/tty0 and/dev/fb*?

A: In a system where the framebuffer device is not enabled, you can use/DEV/TTY0 to access the video card.

Q: What text can I refer to the difference between terminal and console?

A: You can refer to the section on "TERMINAL devices" in documents/devices.txt in the kernel documentation:

In addition, the 8.7 sections of "Linux kernel source code scenario analysis", and the 3.9 sections in "Operating Systems:design and Implementation" (3rd edition of Section 3.8), provide a good introduction to the concept and history of terminal equipment.

In addition, in the "Modern Operating System" also has the introduction of terminal equipment, because with the "Operating systems:design and implementation" the same author, so the text content is similar. One thing to note is that the terminal equipment is divided into 3 categories in Operating systems:design and implementation, while the modern Operating system divides the end hardware devices into 2 categories, the difference being that the former will be X Terminal as a category.
====================================
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.

But does it require a terminal interaction if we telnet to the host or use xterm remotely? Yes, this is the Virtual Terminal Pty (Pseudo-tty)
PTS (pseudo-terminal Slave) is an implementation of Pty, implemented Pseudo-terminal with PTMX (Pty Master).

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. 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. Can be connected to the serial port to experiment.

2. Pseudo Terminal (/dev/pty/)
Pseudo terminal (Pseudo Terminal) is a paired logical terminal device (i.e. master and slave devices, the operation of Master will be reflected on slave), such as/DEV/PTYP3 and/DEV/TTYP3 (or in the device file system, respectively/dev/ PTY/M3 and/DEV/PTY/S3). 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.

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.

In order to obtain a large number of pseudo-terminal equipment special files before using device filesystem, a more complex file name naming method is used. Because there are only 16 Ttyp (TTYP0-TTYPF) of the device files, in order to get more logical device pairs, like Q, R, S and other characters are used instead of 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 a Linux system does not use the method described above and uses the "Pty Master" approach, such as/DEV/PTM3. The corresponding end is automatically created as a/DEV/PTS/3. This makes it possible to provide a Pty pseudo-terminal when 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.
That is: TELNET---> TTYP3 (s3:slave)---> PTYP3 (m3:master)---> GETTY
--------------------------------------
Experiment:
1. Open one or n terminal windows under X
2, #ls/dev/pt*
3, close the terminal window under the X, run again, compare two times output information to understand.
In RHEL4 Environment: one (Master) to many (slave) for the output of/DEV/PTMX/DEV/PTS/1

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 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, which is the following example:
1. # TTY (view current TTY)
/dev/tty1
2, #echo "Test tty0" >/dev/tty0
Test Tty0

Original address: http://blog.csdn.NET/chaofanwei/article/details/17526111

Terminal types for Linux

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.