A Guide to the Linux getty Command for Managing Terminal Sessions

getty is a system program on Linux and Unix systems that handles the initialization and management of physical or virtual terminal (TTY) connections. Its primary function is to listen for a connection on a specified TTY, prompt for a username, and then execute the login program to authenticate the user.

This command is typically included in the util-linux package, which is standard on most Linux distributions. For systems where it's not present, it can be installed via the distribution's package manager.

For Debian/Ubuntu-based systems:

sudo apt install util-linux

For Red Hat/CentOS/Fedora systems:

sudo yum install util-linux

For Alpine Linux:

sudo apk add util-linux

The fundamental syntax for the command is:

getty [OPTIONS] TTY_DEVICE

Here, TTY_DEVICE is the path to the terminal device to be managed, such as tty1 or ttyS0.

Key Command-Line Options

Option Description
-8, --8bits Assume the terminal uses 8-bit data paths.
-a USER, --autologin USER Automatically log in the specified user without a password prompt.
-h, --flow-control Enable hardware flow control (RTS/CTS).
-i, --noissue Suppress the display of /etc/issue before the login prompt.
-J, --noclear Do not clear the screen before showing the login prompt.
-n, --skip-login Do not prompt for login; execute the program specified by --login-program.
-p, --login-pause Wait for a keystroke before displaying the login prompt.
-R, --hangup Perform a virtual hangup on the terminal using vhangup().
-s, --keep-baud Attempt to maintain the existing baud rate after connection.
-t SECS, --timeout SECS Terminate the session if a username is not entered within the specified seconds.
-U, --detect-case Enable support for detecting terminals that send only uppercase characters.

Practical Examples

1. Manage a Specific Virtual Terminal Start getty on the first virtual console (tty1).

getty tty1

2. Configure Automatic Login Automatically log in the user operator on tty3.

getty -a operator tty3

3. Set an Inactivity Timeout Manage tty4 and close the session if no input is received for 45 seconds.

getty -t 45 tty4

4. Suppress the System Issue File Start a session on tty5 without displaying the contants of /etc/issue.

getty -i tty5

5. Disable Screen Clearing Manage tty6 without clearing the screen first.

getty -J tty6

6. Enable Hardware Flow Control Enable RTS/CTS flow control for a serial terminal on ttyS0.

getty -h ttyS0

7. Pause Before Login Prompt Wait for a key press on tty2 before showing the login prompt.

getty -p tty2

8. Perform a Terminal Hangup Initialize tty1 with a virtual hangup.

getty -R tty1

9. Maintain Existing Baud Rate Try to keep the current baud rate when starting getty on ttyS1.

getty -s ttyS1

10. Detect Uppercase-Only Terminals Enable case detection for an older terminal on tty7.

getty -U tty7

11. Skip the Login Prompt Start getty on tty8 without prompting for a login, typically used with a custom program.

getty -n tty8

12. Assume 8-bit Terminal Configure getty for tty9 assuming an 8-bit clean connection.

getty -8 tty9

Important Considerations

  • Running getty typically requires superuser (root) privileges.
  • The command is often configured and launched automatically by the system's init system (e.g., systemd or sysvinit) for standard virtual consoles. Manual invocation is more common for serial terminals.
  • Incorrect configuration can lock you out of a terminal session or cause system boot issues. Test configurations carefully.

Related Commands

  • login: Authenticates a user and starts a session.
  • tty: Prints the filename of the terminal connected to standard input.
  • stty: Changes and prints terminal line settings.
  • who / w: Display information about currently logged-in users.
  • init / telinit: Controls the system runlevel.
  • shutdown, reboot, halt, poweroff: System shutdown and reboot commands.
  • mesg: Controls write access to your terminal.
  • write, wall: Send messages to other users' terminals.

Tags: Linux getty Terminal TTY System Administration

Posted on Sun, 14 Jun 2026 18:13:04 +0000 by leeroy1