June Marie Sobrito / Shutterstock.com

What does the team do tty ? It prints the name of the terminal you are using. TTY stands for Teletype. What is the story behind the team name? This needs more explanation.

Teleprinters from the 1800s

In the 1830s and 1840s, machines known as teleprinters were developed. These machines can send printed messages «over the wire» to remote locations. The messages were typed by the sender on a sort of keyboard. They were printed on paper on the receiving end. They were an evolutionary step in telegraphy, which previously relied on Morse code and similar codes.

Messages were encoded and transmitted, then received, decoded and printed. There were several methods used to encode and decode messages. The most famous and one of the most prolific was patented in 1874 by Émile Baudot, for whom the data rate is named. Its character encoding scheme predates ASCII by 89 years.

Baudot coding eventually became the closest thing to a standard in teleprinter coding, and it was adopted by most manufacturers. Bodo’s original hardware design only had five piano-like keys. The operator had to learn a specific key combination for each letter. As a result, the Baudot coding system was paired with the traditional keyboard layout.

To mark this advance, the machines were called teletypes. This was shortened to teletype and eventually to TTY. So that’s where we get the abbreviation TTY from, but what does telegraphy have to do with it?

ASCII and Telex

When ASCII arrived in 1963, it was adopted by teleprinter manufacturers. Despite the invention and widespread use of the telephone, teleprinters were still gaining momentum.

Telex was a worldwide teleprinter network that allowed written messages to be sent around the world. They were the main means of transmitting written messages in the post-World War II period until the facsimile boom of the 1980s.

Computers have also evolved. They have become able to interact with users in real time and support multiple users. The old batch method of working has become insufficient. People didn’t want to wait 24 hours or longer for their results. Creating stacks of punched cards and waiting for the results was no longer acceptable.

People needed a device that would allow them to enter instructions and send the results back to them. People wanted efficiency.

Teletype repurposed

The teletype was an ideal candidate for an input/output device. After all, it was a device designed to allow messages to be typed, encoded, sent, received, decoded, and printed.

What did the teletype care about if the device on the other end of the connection was not another teletype? As long as it spoke the same coding language and could receive messages and send messages back, the teletype was happy.

And, of course, he used a more or less standard keyboard.

Hardware emulated teletypes

Teletypes became the default means of interacting with the large minicomputers and mainframe computers of the era.

They were eventually replaced by devices that emulated these electromechanical machines using electronics. They had cathode ray tubes (CRTs) instead of paper rolls. They did not jitter when delivering responses from the computer. They allowed hitherto impossible features like moving the cursor around the screen, clearing the screen, highlighting text, etc.

The DEC VT05 was an early example of a virtual teleprinter and the ancestor of the famous DEC VT100. Millions of DEC VT100s have been sold.

Software emulated teletypes

In the Linux desktop environment and other Unix-like operating systems such as macOS, the terminal window and applications such as x-term and Konsole are examples of virtual teletypes. But they are fully emulated by software. They are called pseudo-teletypes. This has been shortened to PTS.

And here comes tty .

What can tty tell us?

Linux has a pseudo-TTY multiplexer that handles connections to all pseudo-TTYs in the Terminal Window (PTS). The multiplexer is the master and the PTS are the slaves. The multiplexer accesses the kernel through a device file located at /dev/ptmx.

Team tty will print the filename of the device that your pseudo teleleptic slave uses to communicate with the master. And this is, in fact, the number of your terminal window.

Let’s see what tty reports for our terminal window:

  TTY 

tty in terminal window

The response shows that we are connected to the device file at /dev/pts/0.

Our window, which is a software emulation of a teletypewriter (TTY), is associated with a pseudo-teletype multiplexer as a pseudo teletypewriter (PTS). And that turns out to be number zero.

Quiet option

Option -s (silent) forces tty do not generate output.

  tty-s 

tty -s in a terminal window

This produces an output value, however:

This will probably be most useful in Bash scripting. But even on the command line, we can only demonstrate how to execute a command if you are working in a terminal window (TTY or PTS session).

  tty -s && echo "In tty" 

tty -s && echo "In tty" in terminal window

Since we are running in a TTY session, our exit code is 0 and the second command is executed.

To Command

Other commands may show your TTY number. Team who displays information for all registered users, including you.

Alec and Mary are remotely connected to a Linux computer. They are connected to PTS one and two.

User Dave is shown as connected to «:0».

This represents the screen and keyboard physically attached to the computer. Although the screen and keyboard are hardware devices, they are still connected to the multiplexer via a device file. tty shows it’s /dev/pts/2.

  кто 
  TTY 

who and you in the terminal window

RELATED: How to determine the current user account in Linux

TTY Access

You can access a full screen TTY session by holding down the Ctrl + Alt keys and pressing one of the function keys.

Ctrl + Alt + F3 will bring up the tty3 login prompt.

tty3 console

If you log in and tty command tty you will see that you are connected to /dev/tty3.

It is not a pseudo-teleptic (emulated by software); it is a virtual teletype (hardware emulated). It uses the screen and keyboard connected to your computer to emulate a virtual teleprinter, just like the DEC VT100 did.

You can use the function keys Ctrl + Alt with the function keys F3 to F6, and you can open four TTY sessions if you wish. For example, you can go to tty3 and press Ctrl + Alt + F6 to go to tty6.

tty6 console

To return to the graphical desktop environment, press Ctrl + Alt + F2.

Pressing Ctrl + Alt + F1 will take you back to the login prompt for your graphical desktop session.

One day, Ctrl + Alt + F1 to Ctrl + Alt + F6 will open full-screen TTY consoles, and Ctrl + Alt + F7 will return you to the graphical desktop environment. If you’re running an older Linux distribution, this is probably how your system behaves.

This has been tested on current versions of Manjaro, Ubuntu and Fedora, and they all behaved like this:

  1. Ctrl+Alt+F1 : returns you to the login screen of the graphical desktop environment.
  2. Ctrl+Alt+F2 : returns you to the graphical desktop environment.
  3. Ctrl+Alt+F3 : opens TTY 3.
  4. Ctrl+Alt+F4 : opens TTY 4.
  5. Ctrl+Alt+F5 : opens TTY 5.
  6. Ctrl+Alt+F6 : opens TTY 6.

Access to these full-screen consoles allows people using command-line-only Linux installations—and many Linux servers are configured that way—to have multiple consoles available.

Have you ever worked on a Linux machine with a graphical desktop environment and something caused your session to hang? You can now switch to one of your TTY console sessions to try and remedy the situation.

you can use top and ps to try to identify the failed application, then use kill to complete it, or just use shutdown to try to close as gracefully as the state of the computer will allow.

RELATED: How to kill processes from the Linux terminal

Three small letters with a big story

Team tty takes its name from a device from the late 1800s that appeared in Unix in 1971, and is still part of Linux and Unix-like operating systems to this day.

There is a real story behind this little guy.

Похожие записи