What is the difference between Pty and tty? What do you mean

Source: Internet
Author: User
Tags telnet program

[Excellent] What is the difference between Pty and tty? What do you mean

Http://www.chinaunix.net Author: george16 published on: 14:31:27
[Comment] [View Original] [AIX discussion board] [close]

What is the difference between Pty and tty? What do you mean

What is the purpose of logging in from Port tty/2? What port is this? Is there any detailed explanation? Control terminal ", what does it mean?

Name
Tty-controlling Terminal

Description
The file/dev/tty is a character file with major number 5 and minor
Number 0, usually of mode 0666 and owner. Group root. TTY. It is a syn-
Onym for the controlling terminal of a process, if any.

In addition to the ioctl () Requests supported by the device that tty
Refers to, the following IOCTL () request is supported:

Tiocnotty
Detach the current process from its controlling terminal, and
Remove it from its current process group, without attaching it
To a new process group (that is, set its process group ID
Zero). This IOCTL () call only works on file descriptors con-
Nected to/dev/tty; this is used by daemon processes when they
Are invoked by a user at a terminal. The process attempts
Open/dev/tty; if the open succeeds, it detaches itself from
Terminal by using tiocnotty, while if the open fails, it is
Obviously not attached to a terminal and does not need to detach
Itself.

Files
/Dev/tty

I don't understand. Are there some specific applications?

George16 replied to: 04:24:53

Tty is the abbreviation of teletype)

A terminal is a type of terminal device. It has multiple types and generally uses tty for short. Tty is short for teletype. Teletype is one of the earliest terminal devices, which is produced by teletype, like a telex typewriter (OR & #61514. The device name is stored in the special file directory/dev/. The special device files on the terminal generally include the following types:
1. Serial Port Terminal (/dev/ttysn)
The serial port terminal (serial port terminal) is a terminal device connected by a computer serial port. The computer regards each serial port as a character device. For some time, these serial port devices are usually called terminal devices, because at that time they were used 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, the device numbers are (), (), and so on, respectively, corresponding to COM1 and com2 in the DOS system. To send data to a port, You can redirect the standard output to these special file names on the command line. For example, if you type echo test>/dev/ttys1 at the command line prompt, the word "test" is sent to the device connected to the ttys1 (com2) port.
2. Pseudo Terminal (/dev/PtY /)
Pseudo Terminal is a pair of logical terminal devices, for example,/dev/ptyp3 and/dev/ttyp3 (or/dev/PtY/m3 and/dev/PtY/S3 in the device file system ). They are not directly related to physical devices. If a program regards ttyp3 as a serial port device, its read/write operations on the port will be reflected in another logical terminal device pair (ttyp3 ). Ttyp3 is the logical device used by another program for read/write operations. In this way, two programs can communicate with each other through this logical device, and one of the programs using ttyp3 thinks they are communicating with a serial port. This is like pipeline operations between logical device pairs.
For ttyp3 (S3), any program designed to use a serial port device can use this logical device. However, for programs that use ptyp3, a dedicated design is required to use the ptyp3 (m3) logical device.
For example, if someone uses a telnet program to connect to your computer online, the telnet program may start to connect to the device ptyp2 (m2) (a Pseudo Terminal port ). At this time, a Getty program should run on the corresponding ttyp2 (S2) port. When Telnet obtains a character from the remote end, the character is passed to the Getty program through m2 and S2, the getty program returns the "login:" string information to the network through S2, m2, and telnet. In this way, the login program communicates with the telnet program through the "Pseudo Terminal. By using appropriate software, you can connect two or more Pseudo Terminal devices to the same physical serial port.
Before using device filesystem, HP-UX AIX and others used complicated naming methods to get 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),/dev/tty is the device special file of the control terminal of the current process. You can run the "PS-Ax" command to check which control terminal the process is connected. For the shell you log on to,/dev/tty is the terminal you are using, and the device number is (5, 0 ). Run the "tty" command to check which actual terminal device it corresponds. /Dev/tty is similar to a connection to the actually used terminal device.
4. Console terminal (/dev/ttyn,/dev/console)
In Unix systems, a computer monitor is usually called a console ). It simulates a Linux terminal (term = Linux), and some special files of the device are associated with it: tty0, tty1, tty2, and so on. When you log on to the console, tty1 is used. With Alt + [F1-F6] keys, we can switch to tty2, tty3 and so on. Tty1-tty6 is called a virtual terminal, and tty0 is an alias of the currently used virtual terminal. The information generated by the system is sent to the terminal. Therefore, no matter which virtual terminal is being used, the system information will be sent to the console terminal.
You can log on to different virtual terminals, so that the system can have several different sessions at the same time. Only the system or Super User Root can write data to/dev/tty0,
5. Other Types
There are many other types of special files for terminal devices for many different character devices. For example,/dev/ttyin terminal devices for ISDN devices. I will not repeat it here

George16 replied to: 04:25:47

I think that I am crazy.

Xlander replied to: 10:02:37

Hehe
Good

Hello_unix: 10:29:01

I have never studied it. I 'd better read it. It's good.

Smartfox365 replied to: 10:43:29

Good, the spirit of the landlord is commendable. Learning.

Rfli replied to: 12:00:01

Nice stuff. Thank you.

Zlg88 replied to: 13:49:09

Good news !!! Refine your work

Unihan replied to: 19:34:02

Pretty good. I also found the answer after I asked a question.

Jason0127 reply to: 00:20:11

Well, I learned another trick.

Shpher replied to: 13:30:40

Good. It's worth learning. The spirit of the landlord: D is the most worth learning !! Top!

Ronaldo9_8: 18:17:12

Pretty good.

Unixboy1106 replied to: 12:26:18

It is also a good way to learn.

Jeffyan replied to: 14:20:58

Good... very detail ..

Karenmok replied to: 14:31:27

I accidentally deleted tty01 in the past. As a result, the machine can only be FTP and login cannot be deleted again.
Tty files are block device files, and FTP files cannot be uploaded.

Http://bbs.chinaunix.net/viewthread.php? Tid = 707301
Reprinted with the author's name and Source Text

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.