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)05/31 Report--
This article mainly introduces "what is tty in linux". In daily operation, I believe many people have doubts about what tty is in linux. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful for you to answer the doubts about "what is tty in linux?" Next, please follow the editor to study!
Tty in linux is the abbreviation of "Teletype", which is a terminal device composed of virtual console, serial port and pseudo terminal device; tty is also a Unix command, which is used to give the name of the current terminal device, and tty can also be used to abbreviate various types of terminal equipment.
The operating environment of this tutorial: linux7.3 system, Dell G3 computer.
What does tty mean in linux
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 (or ), produced by Teletype. The device name is placed under the special file directory / dev/. 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 the marked 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 procedure 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, HP-UX AIX and others used a more complex file name naming method.
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 UNIX 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 message 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. Other types
There are also many other kinds of terminal device special files for many different character devices. For example, / dev/ttyIn terminal devices for ISDN devices and the like. I won't repeat it here.
At this point, the study of "what is tty in linux" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.