## /dev/console https://github.com/torvalds/linux/blob/master/Documentation/admin-guide/serial-console.rst The Linux kernel console can be configured by passing the `console=` boot option. Kernel code which calls `printk()` may write messages to it, e.g. when a device is loaded or an error occurs. Output during early boot is buffered until a console device is found and started. You can pass `console=` multiple times to configure multiple consoles, and messages will be written to all of them. The document above says you can only select one console of each "type". The kernel documentation specifies `/dev/console` as a character device numbered 5:1. On recent (?) kernels, writing to this character device works similar to `printk()`, and will write to all kernel consoles. Previously, it would only write to the "main" console, which is the last console specified. Reading from it appears to still only read from the main console. The initial non-kernel process `init`, aka PID 1, is started with `/dev/console` connected to standard output, standard error, and standard input. A list of configured console devices can be seen by reading `/sys/class/tty/console/active`. Currently [systemd documentation](http://0pointer.de/blog/projects/serial-console.html) claims that the _first_ device shown is the main console, but this does not appear to be true; perhaps this changed as well. The [current kernel documentation](https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-tty) correctly states that the last device shown is the main or "active" console. For some reason it is possible to poll this file for changes. The kernel console is distinct from [`netconsole`](https://www.kernel.org/doc/Documentation/networking/netconsole.txt). `netconsole` is another way to obtain kernel `printk()` messages for troubleshooting, but it cannot be selected as a kernel console. Inside a [`systemd-nspawn`](http://0pointer.de/blog/projects/changing-roots.html) container, the file `/dev/console` is replaced with a pseudo-terminal device, aka PTY. These would be best described as virtual terminal devices. These are created dynamically and are also used to implement graphical terminal emulators like GNOME Terminal, and for remote access like `ssh`. ## /dev/tty0 The Linux TTY [device nodes](https://www.kernel.org/doc/Documentation/admin-guide/devices.txt) `tty1` through `tty63` are always virtual terminals. They are also referred to as VTs, or as virtual consoles. They simulate multiple consoles on top of the physical console device driver. Only one virtual console is shown and controlled at a time. The active terminal can be switched, e.g. using `chvt`, or Ctrl+Alt+F1 through however many function keys you have. You can also read and write to the current VT using `/dev/tty0`. `tty0` is the usual kernel console, e.g. if you did not select one explicitly. "At this time, the system first looks for a VGA card" (which is what VTs run on). The most well-known alternative to this is a "serial console" (e.g. `ttyS0`). "If you don't have a VGA card in your system, the first serial port will automatically become the console." It is not possible to use the VT system on top of a serial console. ## /dev/tty [`/dev/tty` is one of the three standard device files specified by POSIX](https://unix.stackexchange.com/questions/146735/does-posix-require-any-devices) (`/dev/` being one of the three standard directories). Opening it is equivalent to opening the controlling terminal of the current process. The controlling terminal is set when a process first opens a terminal. For example, in `init`, it would refer to `/dev/console`. Detaching from the controlling terminal is one of the steps traditionally required to start a background process, for example a [system logging daemon](https://debian-handbook.info/browse/squeeze/sect.syslog.html). In more modern systems this is performed by the init system, e.g. systemd, when it starts the service. For more technical details see [`man daemon`](https://www.freedesktop.org/software/systemd/man/daemon.html)).