getty
Manage terminal logins on a serial port
SYNOPSIS
getty [options] port [speed [term]]
PARAMETERS
port
The serial port or tty device to open (e.g., tty1, ttyS0). This is a mandatory parameter.
speed
The baud rate for the serial port. If omitted, getty attempts to determine the speed automatically.
term
The terminal type (e.g., vt100, linux). If omitted, the TERM environment variable is used, or 'vt100' is often the default.
-h
Enable hardware flow control (CRTSCTS).
-H
Set the HOSTNAME environment variable.
-l program
Specify a login program instead of /bin/login.
-n
Do not ask for the hostname.
-w
Wait for carrier detect (CD) before starting the login process (relevant for modems).
-m
Obsolete option, ignored for compatibility
DESCRIPTION
The getty command is a core Linux utility responsible for managing virtual terminals (ttys) and serial ports. Its primary function is to open a TTY, set its modes, and initiate the login process.
When a user connects to a system via a terminal (physical or virtual), getty is spawned by init (or a similar process manager) to handle that connection. Getty reads the user's login name and then executes the login program, which authenticates the user and starts a shell. Essentially, getty bridges the gap between the hardware terminal and the login prompt, creating an interactive session.
Historically, getty was crucial for handling serial line connections where devices such as modems were used to connect to the system. Nowadays, with the prevalence of virtual consoles and graphical login managers, getty remains essential for providing text-based login access, particularly in server environments or when troubleshooting system issues. Several variations exist like agetty which are streamlined for specific purposes.
CAVEATS
Misconfiguration of getty can lead to login failures or security vulnerabilities. It's crucial to ensure the correct device name and baud rate are specified, especially when dealing with serial ports. Incorrect terminal types can cause display issues.
VIRTUAL CONSOLES
On modern Linux systems, getty is often responsible for managing the virtual consoles accessible via Ctrl+Alt+F1 through Ctrl+Alt+F7 (or higher depending on the system setup). These consoles provide text-based login environments independent of the graphical display manager.
SYSTEMD INTEGRATION
Many modern Linux distributions use systemd, which provides its own implementations of getty functionality. Systemd's systemd-getty-generator automatically creates getty instances based on the system's configuration.
HISTORY
getty has been a part of Unix-like systems since the early days of computing. It originated as a program to manage serial line connections to mainframe computers and minicomputers. Over time, it has been adapted and enhanced to support virtual consoles and other modern terminal technologies. The basic function of opening a terminal and initiating the login process remains the same, but various implementations and configurations exist depending on the specific operating system and system configuration.