LinuxCommandLibrary

getty

Manage terminal logins on a serial port

SYNOPSIS

getty [options] tty [baud_rate[,baud_rate]] [termtype]

PARAMETERS

-8
    Support 8 bits per character

-a, --autologin
    Automatically log in specified user

-c, --noreset
    Do not reset control mode flags

-E, --issue-from
    Display specified issue file

-f, --remote
    Use named pipe for stdin/stdout

-h, --flow-control
    Enable hardware flow control

-H, --host
    Override hostname in issue

-i
    Do not display issue before login

-I, --init-string
    Set init string for serial port

-j, --chdir


    Chdir before login

-l, --login-program
    Invoke alternative login program

-L, --local-line
    Enable 8 bits, no parity

-m, --extract-baud
    Extract baud rate during connect

-n, --skip-login
    Skip login, go to shell

-N, --nonewline
    Do not print newline before issue

-o, --login-options
    Pass options to login

-O, --image-issue-from
    Display image issue file (conio)

-p, --login-pause
    Pause after failed login

-r, --hangup
    Do vhangup on tty

-R, --chroot
    Change root before login

-s, --keep-baud
    Try same baud rate on reopen

-t, --timeout
    Login prompt timeout in seconds

-U, --utf8
    UTF-8 terminal

-v, --version
    Display version info

-w, --wait-cr
    Wait for CR before issue

--noclear
    Do not clear screen before prompt

--nohostname
    No hostname at login prompt

--long-hostname
    Print full hostname

--erase-char
    Set erase character

--kill-char
    Set kill character

--chroot
    Chroot to directory

--delay
    Delay before prompt (deciseconds)

--nice
    Run login with given nice priority

--reload
    Reload utmp

--skip-login
    Skip /etc/issue

--no-newprivs
    Drop capabilities

--help
    Show help

DESCRIPTION

getty (or agetty in modern Linux) is a system program that initializes terminals for login sessions. It configures serial lines or virtual consoles, detects baud rates, echoes the banner from /etc/issue, and invokes the login program.

On boot, init or systemd starts multiple getty instances for each TTY (e.g., tty1-tty6 for consoles, or serial ports). For virtual terminals, it sets TERM to linux or similar, erases the screen, and prompts for username/password. For serial consoles, it auto-detects speed and handles hardware flow control.

getty supports features like automatic login for kiosks, issue file customization with expansions (%h for hostname, %d for date), and timeouts for unresponsive terminals. It logs sessions to /var/log/wtmp and /var/run/utmp. In SysV init, it's configured in /etc/inittab; in systemd, via getty@tty1.service.

This ensures secure, standardized access to the system shell from physical or remote terminals, bridging hardware to user authentication.

CAVEATS

Must run as root; insecure if misconfigured on exposed serial ports. Baud rate mismatches can hang sessions. Avoid autologin on multiuser systems.
Modern systems prefer systemd over manual inittab.

KEY FILES

/etc/issue: Pre-login banner (expansions: %h=host, %t=time).
/etc/issue.net: For network logins.
/var/log/wtmp, /var/run/utmp: Session records (use last, w to view).

INVOCATION EXAMPLES

Console: getty 38400 tty1
Serial: getty -L 115200 ttyS0 vt100
Systemd: /etc/systemd/system/getty@tty1.service.d/override.conf for options.

SECURITY NOTES

Use -n -i for headless. Escape sequences in /etc/issue can be exploited; validate content.

HISTORY

Originated in early Unix (Version 7, 1979) as part of getty for serial terminals. Evolved in BSD 4.1 (1981) with agtty. Linux util-linux provides agetty since 1990s, replacing older mgetty/fgetty. Integrated with systemd in 2010s for on-demand activation.

SEE ALSO

login(1), sulogin(8), mingetty(8), agetty(8), init(8), inittab(5)

Copied to clipboard