is a daemon that starts login sessions on virtual console terminals,
on demand. It opens the virtual console terminals specified by the
arguments, displays a
prints the login prompt
on each terminal
and waits for user name.
On user action,
in a new process with the terminal the user is typing in as the
then prompts for a password to login with the system and
finally, if the login succeeds, executes the user's login shell.
When the user logs out,
restarts the corresponding virtual console terminal.
Actually almost the whole work is done by a
hostname, login prompt,
waits for user name.
The traditional way to enable logins on virtual console terminals is
to start a bunch of
programs, one for each virtual console terminal, from
As most users rarely login on virtual console terminals nowadays, preferring
graphical logins instead, it seems wasteful to have all those
processes doing nothing but wasting memory.
manages logins on any number of virtual console terminals from a single,
does not use stdin, stdout or stderr and closes them.
in the background, remember to disassociate it from the current controlling
terminal by making it the process group leader of a new session, e.g.:
add something like this to
ng:2345:respawn:/sbin/ngetty tty1 tty2 ... tty6
is available use it to start ngetty from
See the example bellow.
can not open one of the virtual console terminals specified in the
arguments, most likely because that
device node does not exist, no greeting message will be displayed on
that terminal, obviously, and
will simply go on, ignoring the offending terminal.
Create the missing
device and send SIGCHLD to ngetty.
Then it will reopen the new
Instead of sending SIGCHLD you can login and logout on some
This also forces ngetty to reopen the new
It's path is hard-coded in
program nor move it to other location.
If, on user action,
can not execute
in all likelihood because the compiled-in
path does not match your system's
restarts the terminal and redisplays the greeting message.
In any case,
does not output error messages.
It's possible to set different options for
program in file
If the option begin with "=" it's applied for
all tty. If it start with a tty name it's applied only
on current tty.
For security reasons
evaluate the file
only if it has mode:
-rw------- root root /etc/ngetty/Conf
recognizes the following options which might be embedded in the
If a line starts with
it is a comment.
If debug is set
write on terminal
all successfully applied options. Set this on the fist line of
\d (current day)
Fri Jun 01 2007.
Abbreviation for week days (21 bytes). Default is:
Abbreviation for months (36 bytes). Default is:
Change the timezone offset. If the string starts
with slash it's the name of tzfile.
The string is positive number if the local
time zone is east of the Prime Meridian
and negative if it is west.
Turn the echo off just before starting /bin/login. It's similar
to stty -echo.
Print this string before writing out
(default is \012).
tty3=newline=\012I am \l\012
Clear the screen before prompting for the login name with the
string (default is \033c). Examples:
Do not clear the screen before prompting for the login name the
first time after reboot. Example:
Do not call vhangup() to disable writing to this tty by
By default the hostname is only printed until the first dot.
With this option enabled, the full text from gethostname() is shown.
Do not ask for user name. Exec login(1) immediately. Example:
=nousername =login-prompt= Press ENTER to activate \l
Disable login process for some users. The first char after "deny="
is split char. Example:
Enable login process only for the users.
The first char after "allow=" is split char. Example:
Accept only these chars in user name. Default is to
accept only ",-._ 0-9 a-z A-Z".
It's possible to insert here the output of
Here ABC and XYZ are octal numbers. Examples:
Change the issue file. Disable printing of the issue file with:
Change the login app. It's possible to use fgetty's
Read login name over the string.
Default string is 40 bytes long. Example:
Change the login prompt string. Example:
=login-prompt=\033[1;33m\l\033[0;39m \n login:
Change the priority by calling nice().
Sleep this many seconds before printing the file /etc/issue.
Wait at most this many seconds for user name.
Change into this directory before calling the login prog.
Call chroot() with this directory name.
Log the specified user automatically in without asking for
a login name and password. Check the -f option from
Log in automatically only the first time after reboot without asking for
a login name and password.
Replace the environ. The first char after "environ="
is split char. Examples:
Exec this line before printing
The line is executed using
/bin/sh -c line.
It's good idea
to use the full paths here. Example:
tty4=sh-A=exec /bin/ps e -u root tty4=delay=8
Similar to option
This is executed before asking for username.
Ngetty starts login application with options
login -- XYZ # default
login -f XYZ # if autologin-name=XYZ
With this option it's possible to start login appl
with any_string instead of -- or -f.
Using the program ngetty-argv(8) one can start
arbitrary program with different arguments. Two very
dangerous examples are (never try them):
tty4=login-prog=/sbin/ngetty-argv tty5=login-prog=/sbin/ngetty-argv tty4=login-argv=,/bin/login,,-f,%U tty5=login-argv=:-C:/bin/bash:-bash
If ngetty-helper finds stdout or stderr open it exits immediately
with error 100. Ngetty invokes it correctly. See also
the program test-helper.c in source package.
Do not edit the file
Put the configurations in
(the same syntax and permissions as
and after editing it, execute:
cd /etc/ngetty && ./setup
removes comments, merges lines ending with a backslash and
expands the string =tz=AUTO to numeric number.
Then It updates
If ngetty receives SIGTERM it kill all child's PID (first with SIGTERM
and then with SIGKILL) and exit immediately. It does not change UID,
GID and mode of the controlling tty devices.
It does not catch the other signals.
Sending SIGCHLD to ngetty forces it
to reread his internal cache tables
and to restart failed tty devices.
recognizes the following escapes sequences which might be embedded
after login-prompt=, newline=, clear=
or in the
insert the number of users which are currently logged in,
insert the string "1 user" or "<n> users", where <n> is
the number of users currently logged in,
inserts operating system version (uname -v).
inserts a letter with octal code XYZ.
"Linux eos i386 #1 Tue Mar 19 21:54:09 MET 1996" was produced
by putting "\s \n \m \v" into
The program ngetty-argv(8) splits argv on strings,
expands %U and %T to username and tty and then
the application. The first char after "login-argv="
is split char. In the examples above every user logs on tty4
without password and tty5 is always root. To understand better
how ngetty-argv works try as non-root:
ngetty-argv ':/bin/echo:echo:%U: on %T' usr tty3 ngetty-argv ':/bin/sleep:-hacker:39:I am %U on %T' 123 X
One can put also options for ngetty-argv at the beginning.
This program is a hack written for ngetty-helper.
There is no additional code in ngetty-helper and
it's possible to start a program with any args.
It is like a filter between ngetty-helper and login application.
One can easy modify it without touching ngetty-helper.
It's similar to DJB well known argv0(1) and
You can write own such programs
and use them instead of ngetty-argv.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.