getty

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
agetty
is the default getty in Arch Linux, as part of the
util-linux
package.
An alternative is
mingetty
AUR
.
Tips and tricks
Staircase effect
agetty
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.
It is entirely harmless, but in the event it persists once logged, you can fix this behavior with:
$ stty onlcr
See this
forums discussion
on the subject.
Add additional virtual consoles
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
.
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 needed, it is possible to temporarily
start
a
getty@tty
N
.service
service directly.
Automatic login to virtual console
Configuration relies on systemd unit
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
tty
N
, 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
ttyS
N
, where
N
is a number.
Tip
Consider using
greetd
's auto-login feature. It will not auto-login a second time if the initial session exits, but will show a login screen instead.
Virtual console
Create a
drop-in file
for
getty@tty1.service
with the following contents:
/etc/systemd/system/getty@tty1.service.d/autologin.conf
[Service]
ExecStart=
ExecStart=-/sbin/agetty --noreset --noclear --autologin
username
- ${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 file. Both the init system and
startx
can be
silenced
to avoid the interleaving of their messages during boot-up.
See
Silent boot#agetty
for an example virtual console drop-in file which hides the login prompt completely.
The above snippet will cause the loginctl session type to be set to
tty
. If desirable (for example if
starting X automatically
), it is possible to manually set the session type to
wayland
or
x11
by adding
Environment=XDG_SESSION_TYPE=x11
or
Environment=XDG_SESSION_TYPE=wayland
into this file.
If you do not want full automatic login, but also do not want to type your username, see
#Prompt only the password for a default user in virtual console login
.
If you want to use a
tty
other than
tty1
, see
systemd/FAQ#How do I change the default number of gettys?
.
Serial console
Create a
drop-in file
:
/etc/systemd/system/serial-getty@ttyS0.service.d/autologin.conf
[Service]
ExecStart=
ExecStart=-/usr/bin/agetty --noreset --noclear --autologin
username
--keep-baud 115200,57600,38400,9600 - ${TERM}
Nspawn console
To configure auto-login for a
systemd-nspawn
container, override
console-getty.service
by creating a
drop-in file
:
/etc/systemd/system/console-getty.service.d/autologin.conf
[Service]
ExecStart=
ExecStart=-/usr/bin/agetty --noreset --noclear --autologin
username
--keep-baud 115200,57600,38400,9600 - ${TERM}
If
machinectl login
my-container
method is used to access the container, also adjust the
container-getty@.service
template that manages
pts/[0-9]
pseudo ttys:
/etc/systemd/system/container-getty@.service.d/autologin.conf
[Service]
ExecStart=
ExecStart=-/usr/bin/agetty --noreset --noclear --autologin
username
- ${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/skip-username.conf
[Service]
ExecStart=
ExecStart=-/usr/bin/agetty -o '--
username
' --skip-login --noreset --noclear - ${TERM}
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 a
drop-in file
:
/etc/systemd/system/getty@tty1.service.d/noclear.conf
[Service]
TTYVTDisallocate=no
Note
Make sure to remove
quiet
from the
kernel parameters
.
Late KMS starting may cause the first few boot messages to clear. See
Kernel mode setting#Early KMS start
.
Turn off display after timeout
This article or section is a candidate for merging with
Display Power Management Signaling#Linux console
.
Notes:
This tip is essentially about the console blanking, and we have dedicated section on it. (Discuss in
Talk:Getty
)
When the system is used as a server but has a display connected, the display will be turned on forever. To turn off display after 5 minutes create a
drop-in file
. On any key press, display will turn back on.
/etc/systemd/system/getty@tty1.service.d/blankscreen.conf
[Service]
ExecStartPost=-/usr/bin/setterm --blank 5
See also
systemd#Change default target to boot into
The TTY demystified
Wikipedia:tty (unix)