console — system console device
The /dev/console
device provides access to the Linux console.
What the console actually is can vary, and is configurable via the console=
parameter on the kernel command line, supplied to it by the bootstrap kernel loader.
The kernel maintains a list of console devices.
The /dev/console
device maps to the last device in the list.
(Thus application output via /dev/console
differs from kernel console message output, which goes to all devices listed.)
The console=
parameter lists one or more serial port devices (see ttyS(4)), parallel port devices (see lp(4)), or kernel virtual terminal devices (see vt(4)).
The default list in the absence of a parameter is usually tty0
, the currently active kernel virtual terminal; although if the kernel virtual terminal subsystem is configured out it will be something else, with the kernel picking the console device.
/dev/console
is a fully functional terminal device, with a line discipline.
Its input and output are routed via the underlying device by the kernel.
It does not support serial device control.
For that, one must open the actual device underpinning the console.
Nor does it support ioctl()
s peculiar to kernel virtual terminal devices.
Process 1 commences execution with its standard input, output, and error file descriptors open to the console device, which the kernel expects to be available by the name /dev/console
at that point.
The initial root filesystem (initramfs, initrd, or physical on-disc filesystem) should thus have an explicit /dev/console
character device file with the correct major and minor numbers, as no /dev
filesystem is mounted by default at this point (although this is modifiable via a kernel configuration option).
The system console is a character device with major number 5 and minor number 1.
(Compare minor number 2 for ptmx(4) and minor number 0 for tty(4).)
Thus a devtmpfs
filesystem automatically gains a node named console
that denotes this device.
The /dev/console
device file available within a container may differ.
What it is is determined by the applications software that created the container and populated its /dev
directory.
Some container systems have the convention of it being a bind-mounted pseudo-terminal slave side device, for example.
Specifics are beyond the scope of this manual page, which only addresses the kernel-provided device file.
See your container software's documentation.
The /dev/console
device filename for the system console is required in order to conform with the Single Unix Specification (per "Directory Structure and Devices").
This explicitly permits it to be a link to another device.
Linux does not implement it as a link, however.
Opening /dev/console
and writing messages there is an optional functionality of the syslog library.