getty - ArchWiki

# getty

From ArchWiki
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Related articles

- Display manager

A getty is the generic name for a program which manages a terminal line and its connected terminal. Its purpose is to protect the system from unauthorized access. Generally, each getty process is started by systemd and manages a single terminal line.

## Installation

This article or section needs language, wiki syntax or style improvements. See Help:Style for reference.

Reason: Description of TTY settings and "staircase effect" is out of context here. The default number of TTYs can be moved to #Add additional virtual consoles as it does not depend on agetty. (Discuss in Talk:Getty#)

agetty is the default getty in Arch Linux, as part of the util-linux package. It modifies the TTY settings while waiting for a login so that the newlines are not translated to CR-LFs. This tends to cause a "staircase effect" for messages printed to the console. Agetty manages virtual consoles and six of these virtual consoles are provided by default in Arch Linux. They are usually accessible by pressing `Ctrl+Alt+F1` through `Ctrl+Alt+F6`.

Alternatives include:

- mingetty — A minimal getty which allows automatic logins.

  mingettyAUR || mingettyAUR

- fbgetty — A console getty like mingetty, which supports framebuffers.

  http://projects.meuh.org/fbgetty/ || fbgettyAUR

- mgetty — A versatile program to handle all aspects of a modem under Unix.

  http://mgetty.greenie.net/ || mgettyAUR

## Add additional virtual consoles

Open the file `/etc/systemd/logind.conf` and set the option NAutoVTs=6 to the number of virtual terminals that you want at boot.

If you wish to start one temporarily, you can start a getty service at the desired TTY by typing:

    $ systemctl start getty@ttyN.service

## Automatic login to virtual console

Configuration relies on systemd drop-in files to override the default parameters passed to agetty.

Configuration differs for virtual versus serial consoles. In most cases, you want to set up automatic login on a virtual console, (whose device name is `ttyN`, where `N` is a number). The configuration of automatic login for serial consoles will be slightly different. Device names of the serial consoles look like `ttySN`, where `N` is a number.

### Virtual console

Create a drop-in snippet for `getty@tty1.service` with the following contents:

    /etc/systemd/system/getty@tty1.service.d/override.conf

    [Service]
    ExecStart=
    ExecStart=-/usr/bin/agetty --autologin username --noclear %I $TERM

Tip: The option `Type=idle` found in the default `getty@.service` will delay the service startup until all jobs (state change requests to units) are completed in order to avoid polluting the login prompt with boot-up messages. When starting X automatically, it may be useful to start `getty@tty1.service` immediately by adding `Type=simple` into the drop-in snippet. Both the init system and startx can be silenced to avoid the interleaving of their messages during boot-up.

If you do not want full automatic login, but also do not want to type your username, you can replace `--autologin username` with `--skip-login --login-options username`.

If you want to use a tty other than tty1, see systemd FAQ.

### Serial console

Create the following file (and leading directories):

    /etc/systemd/system/serial-getty@ttyS0.service.d/autologin.conf

    [Service]
    ExecStart=
    ExecStart=-/usr/bin/agetty --autologin username -s %I 115200,38400,9600 vt102

### Nspawn console

To configure auto-login for a systemd-nspawn container, override `console-getty.service`:

    /etc/systemd/system/console-getty.service.d/override.conf

    [Service]
    ExecStart=
    ExecStart=-/sbin/agetty --noclear --autologin username --keep-baud console 115200,38400,9600 $TERM

If `machinectl login my-container` method is used to access the container, also add `--autologin username` to `container-getty@.service` template that manages `pts/[0-9]` pseudo ttys:

    /etc/systemd/system/container-getty@.service.d/override.conf

    [Service]
    ExecStart=
    ExecStart=-/sbin/agetty --noclear --autologin username --keep-baud pts/%I 115200,38400,9600 $TERM

## Prompt only the password for a default user in virtual console login

Getty can be used to login from a virtual console with a default user, typing the password but without needing to insert the username. For instance, to prompt the password for `username` on `tty1`:

    /etc/systemd/system/getty@tty1.service.d/override.conf

    [Service]
    ExecStart=
    ExecStart=-/sbin/agetty -n -o username %I

and then

    # systemctl enable getty@tty1

## Have boot messages stay on tty1

By default, Arch has the `getty@tty1` service enabled. The service file already passes `--noclear`, which stops agetty from clearing the screen. However systemd clears the screen before starting it. To disable this behavior, create `/etc/systemd/system/getty@tty1.service.d/noclear.conf`:

    /etc/systemd/system/getty@tty1.service.d/noclear.conf

    [Service]
    TTYVTDisallocate=no

This overrides only `TTYVTDisallocate` for agetty on TTY1, and leaves the global service file `/usr/lib/systemd/system/getty@.service` untouched. See Systemd#Editing provided units.

Note:

- Make sure to remove `quiet` from the kernel parameters.
- Late KMS starting may cause the first few boot messages to clear. See KMS#Early KMS start or KMS#Disabling modesetting.

## See also

- systemd#Change default target to boot into
- The TTY demystified
- Wikipedia:tty (unix)

Categories:

- Boot process
- Linux console

Hidden category:

- Pages or sections flagged with Template:Style