getty
Manage terminal logins on a serial port
SYNOPSIS
getty [options] tty_line [baud_rate [terminal_type [linediscipline]]]
Common usage (e.g., for agetty, a common modern getty implementation):
getty [-h] [-t timeout] [-U user] [-L] port [baud_rate [term_type]]
PARAMETERS
tty_line
The name of the terminal device to open (e.g., tty1, ttyS0). This is typically a pathname relative to /dev/.
baud_rate
The speed (baud rate) at which the terminal should operate. Multiple rates can often be specified, allowing getty to cycle through them.
terminal_type
The value to be set for the TERM environment variable (e.g., vt100, linux).
linediscipline
The line discipline to use for the terminal line (e.g., n_tty, n_hdlc). Less commonly specified directly.
-h or --help
Displays a help message and exits.
-L or --local-only
Configures getty to not call login if the terminal is not local (e.g., for dial-in lines, if remote authentication is handled differently).
-t timeout or --timeout timeout
Specifies the number of seconds getty should wait for a username before exiting if no input is received.
-U user or --autologin user
Automatically logs in the specified user without prompting for a username. Commonly used for embedded systems or specific kiosks.
--noreset
Prevents getty from resetting the terminal's tty modes. Useful for preserving specific settings or for certain serial console configurations.
DESCRIPTION
The getty command is a crucial system utility responsible for preparing a terminal line (either a physical serial port or a virtual console) to accept user logins. It initializes the terminal's characteristics, such as baud rate, parity, and flow control, based on system configuration. After initialization, getty typically displays the contents of the /etc/issue file, which often contains system identification and welcome messages. Following this, it prompts the user to enter their username. Once a username is received, getty usually invokes the login program, passing the entered username as an argument. The login program then handles password authentication and subsequent user session setup. Historically, getty instances were managed by the init process through /etc/inittab, but in modern Linux distributions, systemd manages getty services, typically starting them on demand or for configured terminals. This command is rarely invoked directly by users; rather, it's a fundamental daemon ensuring multi-user access to the system.
CAVEATS
getty itself is often a symbolic link to a specific getty implementation, such as agetty (common on modern Linux) or mingetty (often used for virtual consoles). Therefore, the exact options and behavior can vary slightly depending on which underlying program getty points to. Users typically do not invoke getty directly; it is managed by the system's init process (e.g., systemd on modern systems or init via /etc/inittab on older systems) to handle terminal logins.
THE <I>/ETC/ISSUE</I> FILE
Before prompting for a username, getty typically displays the contents of the /etc/issue file. This file often contains a brief description of the system, OS version, or welcome messages. It's a simple way for administrators to provide information to users before they log in.
PROCESS FLOW
The typical flow involves systemd (or init) starting a getty instance for a specific terminal. getty initializes the terminal, displays /etc/issue, prompts for a username, and then executes login with the provided username. If the user successfully authenticates, login then typically starts a shell for the user. If the user logs out, the terminal line becomes free, and systemd can restart getty to await the next login.
HISTORY
The getty command is one of the oldest and most fundamental utilities in Unix-like operating systems, dating back to early versions of Unix. Its core function—initializing a terminal and prompting for login—has remained remarkably consistent throughout its history. Originally, getty was primarily used for physical serial terminals and dial-up lines. With the advent of virtual consoles and graphical environments, its role extended to managing these as well. Over time, various implementations like agetty and mingetty emerged, offering improved features, efficiency, and flexibility. The transition from the init daemon and its /etc/inittab configuration to the systemd service manager represents the most significant shift in how getty instances are managed and orchestrated on modern Linux distributions, centralizing their configuration within systemd unit files.