Linux slang explained: What is TTY? | Linux China
Introduction: You must have heard the term "TTY" when it comes to Linux and UNIX, but what is it?
The number of words in this article: 2574, the reading time is about 4 minutes
https://linux.cn/article-14093-1.html
Author: Ankush Das
Translator: MjSeven
You must have heard the term "TTY" when talking about Linux and UNIX, but what is this thing?
As a desktop user, does it work for you? do you need it? What can you do with it?
In this article, let me introduce you to these to help you get acquainted with TTYs in Linux.
NOTE: There is no definitive answer to this question, but it has to do with how input/output devices have interacted in the past. So you have to know some history to get a clear picture of the situation.
The History Behind "TTY"
It all started with the Teleprinter in the 1830s.
Teleprinters, which let you send or receive messages over wires, replaced Morse code communication, a method that required two operators to communicate with each other effectively.
A teleprinter can easily deliver messages with only one operator. Although it did not have a keyboard with a modern layout, its system was later improved by Donald Murray in 1901 to include a typewriter-like keyboard.
Murray code reduces the operator's workload for sending messages. This made it possible for the teleprinter to develop into a commercial teletypewriter (Teletypewriter) in 1908. TTY is short for Teletypewriter.
A teletypewriter actually used in London during World War II | Image via Wikipedia
The difference between a teletypewriter and a normal typewriter (typewriter) is that a teletypewriter is connected to a communication device and sends incoming messages directly.
Teletypewriters made it possible for humans to communicate faster over wires without a computer 🔗 en.wikipedia.org .
Since then, the term "TTY" has been around.
(relatively) modern concept
Now, you must be wondering, how did it get into modern computers and Linux?
Originally when teletypewriters entered the market, a few years later semiconductor transistors were developed, which then evolved into microprocessors, ready for the advent of computers.
The original computer did not have the concept of a keyboard, and a punch card was the input method.
A punch card computer program that plugs into a computer instead of typing through a keyboard (TTY) | Image via Wikipedia
With the development of computers, punch cards for batch input were eventually replaced by teletypewriters as a convenient input/output device.
1956 LGP-30 computer with TTY included
As technology advanced, teletypewriters were "virtualized" by electronics. So you don't need a physical, mechanical TTY, but a virtual electronic TTY.
Early computers didn't even have video screens. Characters are printed on paper rather than displayed on the screen. Therefore, you will see the term "print" instead of "display". Video displays were later added to the terminal as technology advanced.
In other words, you've probably heard them called "video terminals." Alternatively, you can call them "physical" terminals.
Later, they evolved into software emulated terminals with greater capabilities and functionality.
This is called a "terminal emulator", like GNOME Terminal or Konsole, or any of the various terminal emulators you'll find on Linux 🔗 itsfoss.com.
So, what exactly is a TTY in Linux?
In Linux or UNIX, the TTY becomes an abstract device. Sometimes it refers to a physical input device, such as a serial port, and sometimes it refers to a virtual TTY that allows the user to interact with the system (see here 🔗 unix.stackexchange.com).
TTY is a subsystem of Linux or UNIX that implements process management, line editing, and session management at the kernel level through the TTY driver.
In the programming context, you also need to dig deeper. But given the scope of this article, this might be an easy definition to understand.
If you're curious, you can check out a somewhat old resource (TTY Demystified 🔗 www.linusakesson.net) that clarifies as much as possible the various technical details of TTY in Linux and UNIX systems.
In fact, whenever you start a terminal emulator on your system or use any kind of shell, it interacts with a virtual TTY (also known as a pseudo-TTY (pseudo-TTY), or PTY).
You can find the associated PTY by typing tty in a terminal emulator.
How to access TTYs in Linux?
TTYs are easy to access in Linux. In fact, I accidentally opened it when I didn't know what it was and panicked about what to do and how to get rid of it.
In most distributions , you can use the following keyboard shortcuts to get a TTY screen:
◈ CTRL + ALT + F1 – lock screen
◈ CTRL + ALT + F2 – Desktop Environment
◈ CTRL + ALT + F3 – TTY3
◈ CTRL + ALT + F4 – TTY4
◈ CTRL + ALT + F5 – TTY5
◈ CTRL + ALT + F6 – TTY6
You can access up to six TTYs. However, the first two shortcuts point to the distro's lock screen and desktop environment.
Other shortcuts will take you to a command line interface.
When should TTYs be used?
Not only is TTY a technical treasure, it's useful even for non-developer users like me.
It should come in handy in situations where the graphical desktop environment freezes. In some cases, rebuilding the desktop environment from a TTY can help resolve program problems.
Alternatively, you can also choose to perform tasks in a TTY, such as updating a Linux system, etc. In these cases, you don't want the display problem to interrupt your process.
At worst, if the GUI becomes unresponsive, you can enter a TTY and restart the computer.
Some users also like to transfer large files with the help of TTY (I am not one of them).
TTY Commands in Linux
When you type tty in a terminal emulator, it will print the filename of the terminal connected to standard input, just as the man page describes it.
In other words, to know the TTY number you're connecting to, just type tty. Also, if there are multiple users remotely connected to the Linux machine, you can use the who command to check which TTY the other users are connected to.
via: https://itsfoss.com/what-is-tty-in-linux/
Author: Ankush Das Topic: lujun9972 Translator: MjSeven Proofreading: wxy
This article was originally compiled by LCTT, and was launched with honor by Linux China
Welcome to reprint in accordance with the CC-BY-NC-SA agreement,
If you want to reprint, please leave a message under the article " Reprint: Official Account Name ",
We will add a whitelist for you to authorize " modification when reprinting articles ".
終端大師 Terminal Master