"Turn" Linux under TTY, console, virtual terminal, serial port, console (console terminal) detailed----good

Source: Internet
Author: User
Tags telnet program

Original URL: http://blog.csdn.net/liaoxinmeng/article/details/5004743

First of all:

1. Neither the terminal nor the console is the concept of personal computers, but the concept of a small, medium-sized mainframe computer shared by many people.
A host, even a lot of terminals, the terminal for the host to provide a human-computer interface, everyone through the terminal using the host resources. The terminal has two kinds of character dumb terminal and graphic terminal.
Console is another human interface, not through the terminal and connected to the host, but through the display card-display and keyboard interface respectively connected to the host, which is the human control of the host's first man-machine interface.
Words back on the PC, PC only console, no terminal. Of course, you can connect the one or two-character dumb terminal on the serial port. But the Linux bias to the POSIX standard of personal computers as a minicomputer to use,
Then on the console through the Getty Software Virtual six-character dummy terminal (or called Console terminal Tty1-tty6) (the number can be adjusted in/etc/inittab) and a graphical terminal, in the virtual graphics terminal can also be through the software (such as RXVT) Virtual Unlimited virtual character dummy terminal (pts/0 ...). Remember, it's all virtual, it's the same, but it's not.
So on a personal computer, there is only one actual console, no terminal, and all terminals are simulated with software on the console.
The personal computer when the host and then through the serial port or network card even the real physical terminal can also, but because the real physical terminal is not cheaper than the PC itself, generally no one to do so.

2. Like other Unix class systems, Linux itself is based on the command line. Try "Ctrl" + "Alt" + "Fx". This is the console , the true nature of Linux. As for the use of the method, in addition to the multi-login logout, the other operation and we are in the Linux graphical Interface (X-window) terminal operation is the same, when the X-window problem or do not run X-window, the operation is mainly done here.
Linux provides more than one (character-dumb) terminal under the console, enabling multiple users to log in at the same time, including logging on at the same time. The console "Alt" + "Fx" is capable of switching to the X (character dummy) terminal. If you need to jump from X-window to the first (character dumb) terminal, you need "Ctrl" + "Alt" + "Fx". In general, if you want to return Xwindow from the console, "" Alt "+7" can be returned to the Xwind graphical interface. (The Linux distribution provides 7 virtual screens, the 1~6 is the console terminal ((character mute) terminal), the 7th one runs X-window. )

3. Control Terminal (/dev/tty) This is a concept in the application, the foreground process has a control terminal, corresponding to this. However, it does not refer to any physical terminal, in fact/dev/tty will be mapped to the current device (through the TTY command can be seen), such as if you are in the console interface (that is, under the character interface) then Dev/tty is mapped to dev/ Tty1-6 between the two (depending on your current console number), but if you are now in the graphical interface (xwindows), then you will find that the current/dev/tty map to the/dev/pts pseudo terminal. For example, you can enter a command #tty then display the current mapping terminal such as/dev/tty1 or/dev/pts/0.

4. Pseudo Terminal (/dev/pty/) This is the development of the terminal, in order to meet the current needs (such as the Network Landing, Xwindow window management).

Pseudo-Terminals (Pseudo Terminal) are paired logical terminal devices, such as/DEV/PTYP3 and/DEV/TTYP3 (or in device file systems
Don't be/dev/pty/m3 and/DEV/PTY/S3). They are not directly related to the actual physical device. If a program sees TTYP3 as a string
Port, its read/write operation on the port is reflected on the other end of the pair (TTYP3) of the logical terminal device. And the TTYP3 is
Another program is used to read and write operations of logical devices. In this way, two programs can communicate with each other through this logical device, where
A program 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. But for the use of PTYP3
program, you need to specifically design to use PTYP3 (m3) logic devices.
For example, if someone uses the Telnet program to connect to your computer on the Internet, the Telnet program may start to connect to the
Ptyp2 (m2) on the standby (a pseudo-terminal port). At this point a Getty program should run on the corresponding TTYP2 (S2) port. When telnet from
When a character is obtained from the remote, the character is passed to the Getty program via M2, S2, and the Getty program passes through the S2, M2, and Telnet programs
Returns the "login:" String information to the network. In this way, the login program communicates with the Telnet program through a "pseudo-terminal". By using the appropriate
Software, you can connect two or more pseudo-terminal devices to the same physical serial port.
Prior to the use of device filesystem, HP-UX Aix was used to obtain a large number of special files for pseudo-terminal devices.
A more complex file name naming method.

5. Console Terminal (/dev/ttyn,/dev/console)
In UNIX systems, computer monitors are often referred to as console terminals (consoles). It simulates a type of terminal (Term=linux) of Linux,
And there are some equipment special files associated with it: Tty0, Tty1, Tty2 and so on. When you log in on the console, you are using Tty1. Use ALT+[F1-F6] Combination
Key, 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,
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 system or Superuser root can
Write to/dev/tty0

The console is a buffering concept that is actually provided for the kernel to print. Our PC, the terminal commonly used is the display and the keyboard composition, our user print and the kernel print all from this terminal to reflect to the user. So, here,/dev/console is connected to/dev/tty0, in fact there are 2 concepts, console and TTY this 2, how to achieve, in fact, console this structure has a device, here is actually tty0 corresponding to a virtual terminal equipment. If, we have a specialized printing kernel device (for example, through the serial port), we put that serial port Register_console, then/dev/console to this serial device. At this time, the kernel printing to this serial device, and the user's printing is related to the above/dev/tty, if the/dev/tty corresponds to/dev/tty0, then the user Print in the window appears. So/dev/console is used to add the console.

6. 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.

That is relative and DOS under the COM1 and COM2, etc...

Summed up: The concept of feeling is still relatively vague, because it may be time to name the sake of it, there are many concepts are very vague!

First: Two modes: Character mode: corresponding to the console, the device file is/dev/tty1-6 (is a console terminal device files), and/dev/tty0 is the current terminal equipment file alias (I think can be said to be linked bar, that is, tty0 refers to the current device files). Graphics mode (Xwindow): corresponding to the Tty7, but in the Xwindow terminal (that is, the window of the input command) corresponds to the device file is/dev/pts/0-(is a pseudo-terminal device file)

About Dev/tty is actually very simple: is a link to the current terminal equipment (a bit like/dev/tty0 bar, but he seems more powerful), we can do this experiment:

Open multiple terminals under Xwindow (Enter the command window): #tty命令, found in each window displayed as # dev/pts/0 #dev/pts/1 #dev/pts/2 ....

Then enter the echo "test" in the #dev/pts/0 terminal to display test >/dev/pts/0 results. Then you enter the echo "test" >/dev/tty in the #dev/pts/0 terminal and you will see that the test string is also displayed in the current window. This means that Dev/tty is actually a link to the current device file.

About/dev/console should be more like a buffer result, to achieve the kernel of the printing, such as the kernel to print the content into the buffer, and then by the console to decide where to print (such as tty0 or serial port, etc.). So/dev/console is used to add the console.

Let's write it down here! This is my reference, if it is wrong, we all help AH.

"Turn" Linux under TTY, console, virtual terminal, serial port, console (console terminal) detailed----good

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.