A tty
(short for "teletypewriter") is a terminal interface, traditionally a physical device, that allows users to interact with a Unix-like operating system. Today, it primarily refers to virtual terminal devices. ttys serve as a bridge between the user and the kernel, enabling input (commands) and output (text) to be exchanged.
Key aspects of ttys:
Types of ttys:
/dev/console
).xterm
, gnome-terminal
, or SSH to provide a terminal interface within a graphical environment or over a network. These are usually in /dev/pts/*
.Naming Convention: Ttys are typically represented as files in the /dev
directory. For example, /dev/tty1
, /dev/tty2
, /dev/pts/0
, etc.
Purpose:
Controlling Terminal: Each process connected to a tty has a controlling terminal. Signals (like Ctrl+C) are sent to all processes in the foreground process group of the controlling terminal.
Utilities: Common commands for working with ttys:
tty
: Prints the name of the current tty.who
: Shows who is logged in and on which ttys.ps
: Can be used to determine which processes are associated with a specific tty.Importance: Ttys are fundamental to the operation of Unix-like systems, providing a crucial link between the user and the operating system kernel. They are essential for command-line interaction, scripting, and remote access.