## /dev/console

https://github.com/torvalds/linux/blob/master/Documentation/admin-guide/serial-console.rst

The Linux kernel console can be selected 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 select 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 initial non-kernel process `init`, aka PID 1, is started with the `/dev/console` connected to standard output, standard error, and standard input. `/dev/console` is the 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 will only read from the main console.

The selected consoles 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, so perhaps it has also been changed. 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). It is used as another way to obtain kernel `printk()` messages for debugging, 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. They are created dynamically and used by 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 terminals on top of the physical console device driver. Only one terminal 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.

## /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 traditional steps in starting a background daemon.