TTY is an abbreviation of teletypewriter, the electromechanical printing terminals over which early time-sharing users interacted with computers. When Unix adopted the term, “tty” came to mean any terminal device, and the name persists in the device files, command names, and system calls of Unix-like systems to this day. A user’s terminal, whether a physical VT100, a serial console, or a window in a graphical emulator, is presented to programs as a tty device.
On Unix the kernel exposes terminals as character device files. The tty(4) manual page describes /dev/tty as “a synonym for the controlling terminal of a process, if any,” a special file with major number 5 and minor number 0 that always refers to whatever terminal the current process is attached to. Each process belongs to a session, and a session may have one controlling terminal; the manual documents how a session leader can detach from its controlling terminal with the TIOCNOTTY request, after which SIGHUP and SIGCONT are sent to the foreground process group. This controlling-terminal machinery is how signals like Control-c reach the right programs and how daemons disconnect from the terminal that launched them.
Between the raw device and the program sits the line discipline, configured through the termios interface. The termios(3) manual page documents the two principal modes of terminal input. In canonical mode (the ICANON flag set), input is assembled line by line and basic line editing such as erase and kill is handled by the kernel before the program ever sees the data. In noncanonical or raw mode, input is delivered byte by byte without line buffering or editing, which is what full-screen programs and editors require. The same interface controls echoing, special characters, flow control, and the translation of carriage returns and newlines.
The line discipline is the reason a simple program can read typed input without implementing keyboard handling itself: by default the kernel collects a whole line, lets the user backspace over mistakes, and only hands over the finished line. Programs that need finer control, such as a shell with command-line editing or a text editor, switch the terminal into raw mode through termios calls, take over input handling, and restore the previous settings on exit. This division between kernel-provided cooked input and application-managed raw input is fundamental to how Unix terminals behave.
The final piece is the pseudo-terminal, or pty. A pty is a pair of devices: a master side held by a program and a slave side that behaves exactly like a real terminal, complete with its own line discipline. Terminal emulators, remote-login servers, and terminal multiplexers like GNU Screen and tmux all work by allocating ptys, attaching a shell to the slave side, and driving the master side themselves. This lets ordinary programs run unmodified, believing they are connected to a hardware terminal, while a graphical window or a network connection stands in for the long-vanished teletypewriter that gave the tty its name.