0

My understanding of tty is is that its means "teletype writers" from the older days, where people had to get teletype writers in order to receive and input data into virtual terminals, my questions are:

  • What does tty represent in Linux?

  • What is tty actually used for in Linux?

  • Why is there so many tty files, such as tty1, tty2, tty3, etc.

How does tty work?

marked as duplicate by Jesse_b, Michael Homer, Kusalananda, Stephen Kitt, ilkkachu Mar 22 at 9:14

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1

In the old days Teletypewriters were typewriters that translated what was typed locally on a mechanical typewriter into EBCDIC or ASCII codes and then transmitted over a cable to a remote computer. Hence the prefix "tele", which means "at a distance". The word "terminal" was sometimes used, because the teletype was the terminal end of the wire where data was entered and transmitted to the computer or receiving station. Each "tty" device was connected via a serial port, because copper wire was expensive and so "parallel" port devices were mainly used for short-distance interfaces like to a local printer. This is before wireless networks were widely used. In the old days of multi-user computer environments you could have multiple "terminal devices", i.e., 'tty' devices connected to the same central computer. This is the original hardware environment in which Unix was developed. That hardware legacy is still with us in the naming of the software components in the Linux operating system.

Today in Linux, the tty is a legacy name used to refer to the user interface for text-based input and output, otherwise known as a "terminal". In Linux systems, there can be multiple tty device "consoles", to support potentially dozens of serial ports or more. tty0 is the current one in use, but Linux allows you to switch to another session by changing to a different tty, e.g., tty1. Linux (e.g., Ubuntu) supports up to 6 ttys by default, but this number is configurable.

In practical terms, think of a tty as a serial communication channel that a Linux session uses to communicate with a user.

How it works is that there is a parsing process bound to the tty session that parses the user's input and passes valid commands to the computer to execute.

  • 1
    If you want to know more detail, check out this post, which goes into considerably more detail. unix.stackexchange.com/questions/4126/… – Rich Lysakowski PhD Mar 21 at 21:47
  • 1
    so basically in the old days, a teletype writter was used to input and output things from terminals, and since then the termanology for a text-based input/output system i.e the terminal has not changed so its known as tty? if this is wrong please correct me. Also what is the tty file in the /dev directory used for? is there any particular use for this file? – Qasim Mar 21 at 22:36
  • 1
    Yes, "tty" is a legacy hardware name for a communication channel still usable today. Today a "tty" can be used as a member of a pair of virtual devices, i.e., paired with a Pseudo Terminal "ptty" like "/dev/ptyp3" and "/dev/ttyp3." There is no physical device directly associated with either of them, not even a serial port connector. But ttyp3 is like a serial port, and reads and writes to that port and the message appears on the other member of the pair. It's something like a "pipe" between these two tty's. See tldp.org/HOWTO/Text-Terminal-HOWTO-7.html for more. – Rich Lysakowski PhD Apr 8 at 23:20

Not the answer you're looking for? Browse other questions tagged or ask your own question.