In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces the example analysis of terminal special equipment files in Linux, which is very detailed and has certain reference value. Friends who are interested must finish reading it!
Terminal is a kind of character device, which has many types, and tty is usually used to refer to various types of terminal devices. Tty is the abbreviation of Teletype. The Teletype is the earliest terminal device, much like a teletypewriter, made by Teletype. Under the device special file directory / dev/ of the Linux system, there are generally the following types of terminal special device files:
1. Serial port terminal (/ dev/ttySn)
A serial port terminal (Serial Port Terminal) is a terminal device connected using a computer serial port. The computer treats each serial port as a character device. There was a time when these serial port devices were often called terminal devices because their greatest use at that time was 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., and the device numbers are (4je 0), (4je 1), etc., respectively, corresponding to COM1, COM2 and so on under the DOS system. To send data to a port, you can redirect standard output to these special file names on the command line. For example, typing: echo test > / dev/ttyS1 at the command line prompt sends the word "test" to the device connected to the ttyS1 (COM2) port.
two。 Pseudo terminal (/ dev/pty/)
Pseudo terminals (Pseudo Terminal) are pairs of logical terminal devices, such as / dev/ptyp3 and / dev/ttyp3 (or / dev/pty/m3 and / dev/pty/s3, respectively, in the device file system). They are not directly related to the actual physical equipment. If a program treats ttyp3 as a serial port device, its read / write operations on that port will be reflected on another pair of logical terminal devices (ttyp3). Ttyp3 is the logical device used by another program to read and write. In this way, two programs can communicate with each other through this logical device, and one of the programs that uses ttyp3 thinks it is communicating with a serial port. This is very much like a pipeline 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, they need to be specially designed to use ptyp3 (m3) logic devices. For example, if someone uses the telnet program to connect to your computer online, the telnet program may begin to connect 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 fetches a character from the remote end, the character is passed to the getty program through m2, S2, and the getty program returns "login:" string information to the network through S2, m2, and telnet programs. In this way, the login program communicates with the telnet program through the "pseudo terminal". By using the appropriate software, two or more pseudo terminal devices can be connected to the same physical serial port. Before using the device file system (device filesystem), in order to get a large number of pseudo terminal device special files, a more complex file name naming method was used. Because there are only 16 ttyp (ttyp0-ttypf) device files, in order to get more logical device pairs, characters such as Q, r, s are used instead of p. For example, ttys8 and ptys8 are a pseudo-terminal pair. However, this naming method is still used in Linux systems such as RedHat. However, Unix98 on Linux systems does not use the above method, but uses the "pty master" method, such as / dev/ptm3. Its counterpart is automatically created as / dev/pts/3. In this way, a pty pseudo terminal can be provided 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 "file" / dev/pts/3 appears to be an item in the device file system, it is actually a completely different file system.
3. Control terminal (/ dev/tty)
If the current process has a control terminal (Controlling Terminal), then / dev/tty is the device special file of 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 the shell,/dev/tty you are logged in to is the terminal you are using, the device number is (5pc0). Use the command "tty" to see which actual end device it corresponds to. / dev/tty is somewhat similar to a connection to the actual terminal device used.
4. Console terminal (/ dev/ttyn, / dev/console)
In Linux systems, computer monitors are often called console terminals (Console). It simulates a terminal (TERM=Linux) of type Linux and has some device-specific files associated with it: tty0, tty1, tty2, and so on. When you log in on the console, you are using tty1. When using the Alt+ [F1-F6] key combination, we can switch to tty2, tty3, etc. Tty1-tty6 and so on are called virtual terminals, and tty0 is an alias of the virtual terminal currently used, and the information generated by the system will be sent to the terminal. Therefore, no matter which virtual terminal is currently in use, the system information will be sent to the console terminal. You can log in to different virtual terminals, so that the system can have several different sessions at the same time. Only the system or superuser root can write to / dev/tty0.
5 Virtual Terminal (/ dev/pts/n)
Pseudo terminal in Xwindows mode.
Another person explained that each remote connection produces a pst device.
6. Other types
In the Linux system, there are other kinds of terminal device special files for many different character devices. For example, / dev/ttyIn terminal devices for ISDN devices and the like.
The above is all the contents of the article "sample Analysis of Terminal Special device Files in Linux". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.