TTY和GNOME终端的区别是什么?

时间:2022-05-11 17:31:40

Operating system like ubuntu, debian having the GNOME terminal for real time usage. But, at the same time ctrl+alt+f2 shows the terminal as a full fledged CUI. If the tty command is executed in GNOME terminal, it shows the output like /dev/pts/3,4 etc. But, in the CUI environment it shows "/dev/tty2". So, what is the difference between these terminals.

操作系统,如ubuntu, debian有GNOME终端实时使用。但是,与此同时,ctrl+alt+f2显示了完整的CUI。如果tty命令在GNOME终端中执行,它会显示输出,比如/dev/pts/3、4等等。但是在CUI环境中,它会显示“/dev/tty2”。那么,这些终端之间的区别是什么。

2 个解决方案

#1


3  

This stems from way back when you had a number of fixed screens attached to the unix box. These had /dev/tty1,2,... as device file as the number was known beforehand and the allocation of physical device vs. device file was fixed.

这源于您在unix框中附加了许多固定屏幕的时候。这些/dev/tty1 2…作为设备文件,数字是事先知道的,物理设备与设备文件的分配是固定的。

When you dialed in to the machine or had remote connections, the "terminal" would be allocated dynamically and be called "pseudo-terminals", hence the device file /dev/pts/3,4... Probably they have their own folder because there can be so many and it would clutter the /dev directory if they would be all in there. The number can vary according to the number of connections and the device number can be recycled.

当您拨号进入机器或拥有远程连接时,“终端”将被动态分配,并被称为“伪终端”,因此设备文件/dev/pts/3、4……它们可能有自己的文件夹,因为可能有很多,如果它们都在那里,就会使/dev目录变得混乱。这个数字可以根据连接的数量而变化,并且设备号码可以回收。

The /dev/ttyN are still there for those "default" terminals that you can access using ctrl-alt-f2 etc.

对于那些您可以使用ctrl-alt-f2等访问的“默认”终端,/dev/ttyN仍然存在。

By the way the name tty itself even comes from the era before terminals, and stems from "tele typewriter", see https://en.wikipedia.org/wiki/Teleprinter

顺便说一句,tty这个名字甚至来源于终端出现之前的时代,来源于“tele typewriter”(https://en.wikipedia.org/wiki/Teleprinter)

#2


0  

Linux (like the BSDs) has one or more virtual consoles (a feature dating back at least to Xenix in the mid-1980s) which are implemented as programs in the kernel. If you are connected via one of those, they have names such as /dev/tty01. From your standpoint, those are (notwithstanding "virtual") real terminals.

Linux(像BSDs)有一个或多个虚拟控制台(至少可以追溯到20世纪80年代中期的Xenix),这些控制台作为程序在内核中实现。如果您通过其中的一个连接,它们有名称,如/dev/tty01。从您的角度来看,这些是(尽管是“虚拟的”)真实的终端。

In contrast, there are terminals which are not real ("pseudo") because they have no definite assignment to "hardware". Linux (again like other systems) provides Unix98 pseudo-terminals, which tty shows as the slave side device /dev/pts3/, etc. (see Pseudo Terminals in Text-Terminal-HOWTO). There was an earlier, intermediate stage of pseudo-terminals which differ more across platforms; Linux implemented the BSD-flavor during the 1990s.

相反,有些终端不是真实的(“伪”),因为它们没有对“硬件”进行明确的分配。Linux(与其他系统一样)提供了Unix98伪终端,tty将其显示为从端设备/dev/pts3/,等等(参见文本终端- howto中的伪终端)。有一个早期的,中间阶段的伪终端在不同的平台上差异更大;Linux在20世纪90年代实现了bsd风格。

Terminal emulators (discounting the virtual consoles which technically are terminal emulators, but widely regarded as "hardware"), do not have direct access to the computer's real/virtual consoles. They use the pseudo-terminal interface to the kernel's terminal driver. That requires the terminal emulator to perform the actual input/output to the visible "terminal" (what you see). Both virtual- and pseudo-terminals share much of the same code in the kernel's terminal driver, which implements things such as your erase character.

终端模拟器(不包括技术上属于终端模拟器的虚拟控制台,但被广泛认为是“硬件”),不能直接访问计算机的真实/虚拟控制台。他们使用伪终端接口到内核的终端驱动程序。这要求终端仿真器执行对可见“终端”(您看到的)的实际输入/输出。虚拟和伪终端都在内核的终端驱动程序*享大部分相同的代码,该驱动程序实现诸如删除字符之类的东西。

In the OP's question, gnome-terminal happens to be one of several terminal emulators which use this feature.

在OP的问题中,gnome-terminal碰巧是使用这个特性的几个终端模拟器之一。

For additional discussion, see

额外的讨论,请参阅

#1


3  

This stems from way back when you had a number of fixed screens attached to the unix box. These had /dev/tty1,2,... as device file as the number was known beforehand and the allocation of physical device vs. device file was fixed.

这源于您在unix框中附加了许多固定屏幕的时候。这些/dev/tty1 2…作为设备文件,数字是事先知道的,物理设备与设备文件的分配是固定的。

When you dialed in to the machine or had remote connections, the "terminal" would be allocated dynamically and be called "pseudo-terminals", hence the device file /dev/pts/3,4... Probably they have their own folder because there can be so many and it would clutter the /dev directory if they would be all in there. The number can vary according to the number of connections and the device number can be recycled.

当您拨号进入机器或拥有远程连接时,“终端”将被动态分配,并被称为“伪终端”,因此设备文件/dev/pts/3、4……它们可能有自己的文件夹,因为可能有很多,如果它们都在那里,就会使/dev目录变得混乱。这个数字可以根据连接的数量而变化,并且设备号码可以回收。

The /dev/ttyN are still there for those "default" terminals that you can access using ctrl-alt-f2 etc.

对于那些您可以使用ctrl-alt-f2等访问的“默认”终端,/dev/ttyN仍然存在。

By the way the name tty itself even comes from the era before terminals, and stems from "tele typewriter", see https://en.wikipedia.org/wiki/Teleprinter

顺便说一句,tty这个名字甚至来源于终端出现之前的时代,来源于“tele typewriter”(https://en.wikipedia.org/wiki/Teleprinter)

#2


0  

Linux (like the BSDs) has one or more virtual consoles (a feature dating back at least to Xenix in the mid-1980s) which are implemented as programs in the kernel. If you are connected via one of those, they have names such as /dev/tty01. From your standpoint, those are (notwithstanding "virtual") real terminals.

Linux(像BSDs)有一个或多个虚拟控制台(至少可以追溯到20世纪80年代中期的Xenix),这些控制台作为程序在内核中实现。如果您通过其中的一个连接,它们有名称,如/dev/tty01。从您的角度来看,这些是(尽管是“虚拟的”)真实的终端。

In contrast, there are terminals which are not real ("pseudo") because they have no definite assignment to "hardware". Linux (again like other systems) provides Unix98 pseudo-terminals, which tty shows as the slave side device /dev/pts3/, etc. (see Pseudo Terminals in Text-Terminal-HOWTO). There was an earlier, intermediate stage of pseudo-terminals which differ more across platforms; Linux implemented the BSD-flavor during the 1990s.

相反,有些终端不是真实的(“伪”),因为它们没有对“硬件”进行明确的分配。Linux(与其他系统一样)提供了Unix98伪终端,tty将其显示为从端设备/dev/pts3/,等等(参见文本终端- howto中的伪终端)。有一个早期的,中间阶段的伪终端在不同的平台上差异更大;Linux在20世纪90年代实现了bsd风格。

Terminal emulators (discounting the virtual consoles which technically are terminal emulators, but widely regarded as "hardware"), do not have direct access to the computer's real/virtual consoles. They use the pseudo-terminal interface to the kernel's terminal driver. That requires the terminal emulator to perform the actual input/output to the visible "terminal" (what you see). Both virtual- and pseudo-terminals share much of the same code in the kernel's terminal driver, which implements things such as your erase character.

终端模拟器(不包括技术上属于终端模拟器的虚拟控制台,但被广泛认为是“硬件”),不能直接访问计算机的真实/虚拟控制台。他们使用伪终端接口到内核的终端驱动程序。这要求终端仿真器执行对可见“终端”(您看到的)的实际输入/输出。虚拟和伪终端都在内核的终端驱动程序*享大部分相同的代码,该驱动程序实现诸如删除字符之类的东西。

In the OP's question, gnome-terminal happens to be one of several terminal emulators which use this feature.

在OP的问题中,gnome-terminal碰巧是使用这个特性的几个终端模拟器之一。

For additional discussion, see

额外的讨论,请参阅