pty和tty是什么意思?

时间:2022-01-15 00:13:04

I noticed there are many mentions of pty and tty in some opensource projects, could someone can tell me what do they mean and what is the difference between them? Thanks!

我注意到在一些opensource项目中有很多关于pty和tty的提到,有人能告诉我它们是什么意思吗?它们之间的区别是什么?谢谢!

4 个解决方案

#1


172  

"tty" originally meant "teletype" and "pty" means "pseudo-teletype".

“tty”原意是“电传打字”和“pty”,意思是“伪电传”。

In UNIX, /dev/tty* is any device that acts like a "teletype", ie, terminal. (Called teletype because that's what we had for terminals in those benighted days.)

在UNIX中,/dev/tty*是任何类似于“teletype”(即终端)的设备。(这就是所谓的电传打字电报,因为这是我们在那些黑暗的日子里所拥有的。)

A pty is a pseudotty, a device entry that acts like a terminal to the process reading and writing there, but managed by something else. They first appeared (as I recall) for X Windows and screen and the like, where you needed something that acted ilke a terminal but could be used from another program.

pty是一个伪tty,它是一个设备条目,它就像一个终端,在那里读取和写入过程,但是由其他东西管理。他们第一次出现(我记得)是在X窗口和屏幕上,在那里你需要一些可以作为终端的东西,但可以从另一个程序中使用。

#2


196  

A tty is a terminal (it stands for teletype - the original terminals used a line printer for output and a keyboard for input!). A terminal is a basically just a user interface device that uses text for input and output.

tty是一个终端(它代表电传打字机),原来的终端使用一个行打印机输出,一个键盘输入!终端基本上只是一个用户接口设备,它使用文本输入和输出。

A pty is a pseudo-terminal - it's a software implementation that appears to the attached program like a terminal, but instead of communicating directly with a "real" terminal, it transfers the input and output to another program.

pty是一个伪终端——它是一个软件实现,它像一个终端一样出现在附加的程序中,但是它没有直接与一个“真正的”终端通信,而是将输入和输出传输到另一个程序。

For example, when you ssh in to a machine and run ls, the ls command is sending its output to a pseudo-terminal, the other side of which is attached to the SSH daemon.

例如,当您ssh到一台机器并运行ls时,ls命令将其输出发送到一个伪终端,另一端连接到ssh守护进程。

#3


14  

tty: teletype. Usually refers to the serial ports of a computer, to which terminals were attached.

tty:电传打字机。通常指计算机的串行端口,连接到终端。

pty: pseudoteletype. Kernel provided pseudoserial port connected to programs emulating terminals, such as xterm, or screen.

企业:pseudoteletype。内核提供了与程序仿真终端(如xterm或screen)连接的伪串行端口。

#4


11  

If you run the mount command with no command-line arguments, which displays the file systems mounted on your system, you’ll notice a line that looks something like this: none on /dev/pts type devpts (rw,gid=5,mode=620) This indicates that a special type of file system, devpts , is mounted at /dev/pts .This file system, which isn’t associated with any hardware device, is a “magic” file system that is created by the Linux kernel. It’s similar to the /proc file system

如果运行mount命令没有命令行参数,显示的文件系统安装在你的系统,你会看到一个这样行:没有/dev/pts类型开发(rw,gid = 5,模式= 620)这表明一种特殊类型的文件系统,开发,是安装在/dev/pts。文件系统,它不与任何硬件设备,是一个“神奇”的文件系统创建的Linux内核。它类似于/proc文件系统。

Like the /dev directory, /dev/pts contains entries corresponding to devices. But unlike /dev , which is an ordinary directory, /dev/pts is a special directory that is cre- ated dynamically by the Linux kernel.The contents of the directory vary with time and reflect the state of the running system. The entries in /dev/pts correspond to pseudo-terminals (or pseudo-TTYs, or PTYs).

与/dev目录一样,/dev/pts包含与设备对应的条目。但是与/dev不同的是,/dev/pts是一个特殊的目录,由Linux内核动态地进行cre。目录的内容随时间变化,反映了运行系统的状态。/dev/pts中的条目对应于伪终端(或伪ttys或PTYs)。

Linux creates a PTY for every new terminal window you open and displays a corre- sponding entry in /dev/pts .The PTY device acts like a terminal device—it accepts input from the keyboard and displays text output from the programs that run in it. PTYs are numbered, and the PTY number is the name of the corresponding entry in /dev/pts .

Linux为你打开的每一个新的终端窗口创建一个PTY,并在/dev/pts中显示一个corre- sponding条目。PTY设备就像一个终端设备,它接受来自键盘的输入,并显示运行在其中的程序的文本输出。PTYs是编号的,PTY编号是/dev/pts中相应条目的名称。

For example, if the new terminal window’s PTY number is 7, invoke this command from another window: % echo ‘I am a virtual di ’ > /dev/pts/7 The output appears in the new terminal window.

例如,如果新的终端窗口的PTY编号为7,则从另一个窗口调用此命令:% echo ' I am a virtual di ' > /dev/ pts7,输出将出现在新的终端窗口中。

#1


172  

"tty" originally meant "teletype" and "pty" means "pseudo-teletype".

“tty”原意是“电传打字”和“pty”,意思是“伪电传”。

In UNIX, /dev/tty* is any device that acts like a "teletype", ie, terminal. (Called teletype because that's what we had for terminals in those benighted days.)

在UNIX中,/dev/tty*是任何类似于“teletype”(即终端)的设备。(这就是所谓的电传打字电报,因为这是我们在那些黑暗的日子里所拥有的。)

A pty is a pseudotty, a device entry that acts like a terminal to the process reading and writing there, but managed by something else. They first appeared (as I recall) for X Windows and screen and the like, where you needed something that acted ilke a terminal but could be used from another program.

pty是一个伪tty,它是一个设备条目,它就像一个终端,在那里读取和写入过程,但是由其他东西管理。他们第一次出现(我记得)是在X窗口和屏幕上,在那里你需要一些可以作为终端的东西,但可以从另一个程序中使用。

#2


196  

A tty is a terminal (it stands for teletype - the original terminals used a line printer for output and a keyboard for input!). A terminal is a basically just a user interface device that uses text for input and output.

tty是一个终端(它代表电传打字机),原来的终端使用一个行打印机输出,一个键盘输入!终端基本上只是一个用户接口设备,它使用文本输入和输出。

A pty is a pseudo-terminal - it's a software implementation that appears to the attached program like a terminal, but instead of communicating directly with a "real" terminal, it transfers the input and output to another program.

pty是一个伪终端——它是一个软件实现,它像一个终端一样出现在附加的程序中,但是它没有直接与一个“真正的”终端通信,而是将输入和输出传输到另一个程序。

For example, when you ssh in to a machine and run ls, the ls command is sending its output to a pseudo-terminal, the other side of which is attached to the SSH daemon.

例如,当您ssh到一台机器并运行ls时,ls命令将其输出发送到一个伪终端,另一端连接到ssh守护进程。

#3


14  

tty: teletype. Usually refers to the serial ports of a computer, to which terminals were attached.

tty:电传打字机。通常指计算机的串行端口,连接到终端。

pty: pseudoteletype. Kernel provided pseudoserial port connected to programs emulating terminals, such as xterm, or screen.

企业:pseudoteletype。内核提供了与程序仿真终端(如xterm或screen)连接的伪串行端口。

#4


11  

If you run the mount command with no command-line arguments, which displays the file systems mounted on your system, you’ll notice a line that looks something like this: none on /dev/pts type devpts (rw,gid=5,mode=620) This indicates that a special type of file system, devpts , is mounted at /dev/pts .This file system, which isn’t associated with any hardware device, is a “magic” file system that is created by the Linux kernel. It’s similar to the /proc file system

如果运行mount命令没有命令行参数,显示的文件系统安装在你的系统,你会看到一个这样行:没有/dev/pts类型开发(rw,gid = 5,模式= 620)这表明一种特殊类型的文件系统,开发,是安装在/dev/pts。文件系统,它不与任何硬件设备,是一个“神奇”的文件系统创建的Linux内核。它类似于/proc文件系统。

Like the /dev directory, /dev/pts contains entries corresponding to devices. But unlike /dev , which is an ordinary directory, /dev/pts is a special directory that is cre- ated dynamically by the Linux kernel.The contents of the directory vary with time and reflect the state of the running system. The entries in /dev/pts correspond to pseudo-terminals (or pseudo-TTYs, or PTYs).

与/dev目录一样,/dev/pts包含与设备对应的条目。但是与/dev不同的是,/dev/pts是一个特殊的目录,由Linux内核动态地进行cre。目录的内容随时间变化,反映了运行系统的状态。/dev/pts中的条目对应于伪终端(或伪ttys或PTYs)。

Linux creates a PTY for every new terminal window you open and displays a corre- sponding entry in /dev/pts .The PTY device acts like a terminal device—it accepts input from the keyboard and displays text output from the programs that run in it. PTYs are numbered, and the PTY number is the name of the corresponding entry in /dev/pts .

Linux为你打开的每一个新的终端窗口创建一个PTY,并在/dev/pts中显示一个corre- sponding条目。PTY设备就像一个终端设备,它接受来自键盘的输入,并显示运行在其中的程序的文本输出。PTYs是编号的,PTY编号是/dev/pts中相应条目的名称。

For example, if the new terminal window’s PTY number is 7, invoke this command from another window: % echo ‘I am a virtual di ’ > /dev/pts/7 The output appears in the new terminal window.

例如,如果新的终端窗口的PTY编号为7,则从另一个窗口调用此命令:% echo ' I am a virtual di ' > /dev/ pts7,输出将出现在新的终端窗口中。