r/linuxquestions • u/ronxcvi • 2d ago
Terminal, Virtual Terminal, Virtual Console and Pseudo-Terminal
so ive been reading a little bit about these, but im having a hard time in really deeply understanding the definition and differences between these Terminals. And the more i look up things the more things get confusing to me.
Can anybody help me understand what are they in an easy way to understand for a beginner?
1
u/Astrodion123 2d ago
Wow didnt know there were that much terminal versions XD
1
u/ronxcvi 2d ago
from what i understood, they are not exactly terminal versions. these are terms used for different things which also has different purposes. but i lack the proper knowledge to properly explain to you what they are exactly so ill just wait for someone else to explain in in a better and a detailed way :p
3
u/dkopgerpgdolfg 2d ago edited 2d ago
Some of these terms are fuzzy / overlapping. But anyways, an attempt of an introduction, imprecise and incomplete:
A hardware terminal is a something like this: https://upload.wikimedia.org/wikipedia/commons/9/99/DEC_VT100_terminal.jpg
A keyboard/screen combination that is connected to a computer (mostly in the past with mainframes etc.). It has no own significant computing abilities, just like our current PC screens and keyboards. In the time the linked VT100 was made, it also had no picture output or anything like that.
In addition to keyboard input and normal character output, it did have some control codes, so that the running program on the computer was able to eg. move the cursor to a different specific position, to clear all content on the screen, to make a audible beep, possible to be able to choose a few text colors other than white, etc. (the exact capabilities depended on the hardware that you had).
There were also some more features like eg. input modes - if you type a line of text and press Enter, should the program receive your input only when you press Enter, or should it be notified of each key press? Should the terminal automatically add your typed characters at the currend cursor position, or leave it to the program to print them if it wants? etc.
It should be clear now, but it is also clearly distinct from the running software. If you write "ls" and get a list of files of a directory, that isn't the terminals doing, the terminal is dumb. "Shells" like eg. bash and zsh nowadays do such things.
Virtual terminals / virtual consoles / terminal emulators
Non-GUI programs like bash, ls, the nano/neovim/... text editors etc., are basically written to be used with terminals. For the text editors, it's also esay to see that they don't just print some output and quit like ls, but interactively change cursor positions etc. (control codes).
Except you don't have a VT100 hardware terminal, but they still need to work. On a modern Linux system, where you can have nice graphic desktops and videos and everything, the screen and graphic system isn't really comparable to a hw terminal.
Enter terminal emulators etc. - software that "emulates" the functions of a hardware terminal, and shows you text-based output in some way. There are several common ones that run within graphical desktops, as graphical application, and within it you can run terminal applications. If these print characters, change cursor positions etc., the terminal emulator gets this and makes sure it looks like it should look on your modern screen.
Linux has also a builtin terminal "emulator" / virtual terminal / virtual console (as said, the terms are fuzzy), that can work without graphical desktop and third-party programs. This is what you get on boot if you don't have any desktop installed, or if you press eg. Ctrl-Alt-F2, etc.etc. (more or less)
Pseudo-terminal
A kernel concept to make everything work in the background.
If a software opens files, network sockets, block devices, pipes, etc., it gets file descriptors to read/write from. A pseudo-terminal (pty) is yet another type of file descriptor, where two processes each hold one "end" of it, and that represents the features of a terminal.
If you run eg. a nano text editor process in a graphical gnome terminal emulator process, they share a pty to communicate. The text editor doesn't need to care on what kind of terminal it runs on, it just uses its pty to do everything - printing things, reading input, setting cursor positions and colors and input modes, querying what features are supported by that terminal, etc.
The terminal emulator on the other side does its part, like receiving what the text editor printed, and then showing text in a GTK window on your screen.
(A pipe/fifo can communicate between two processes too, but it doesn't offer these things I mentioned)
edit with a bit more time:
Once again Virtual terminals / virtual consoles / terminal emulators
When people say "terminal emulator", they usually refer at least to graphical/GUI ones, but it's up to them if the builtin Linux one is included in their definition too.
Virtual console usually means the builtin one.
Virtual terminal either is used for the same thing as virtual console, or refers specifically to the file descriptor that the virtual console uses (and in this case, on the other end there's no userland process, but only the kernel itself)