what is the difference between TTY and GNOME terminal

1.3k views Asked by At

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.

2

There are 2 answers

0
geert3 On

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.

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.

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

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

2
Thomas Dickey On

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.

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.

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.

For additional discussion, see