Linux console: Difference between revisions
imported>LinuxGuru fixing |
change |
||
| Line 1: | Line 1: | ||
{{Short description|Console of the Linux kernel}} | {{Short description|Console of the Linux kernel}} | ||
[[File:Simplified Structure of the Linux Kernel.svg|thumb|Simplified Structure of the Linux Kernel: VT subsystem]] | [[File:Simplified Structure of the Linux Kernel.svg|thumb|Simplified Structure of the Linux Kernel: VT subsystem]] | ||
[[Image:Knoppix-3.8-boot.png|thumb|right|Framebuffer console showing [[ | [[Image:Knoppix-3.8-boot.png|thumb|right|Framebuffer console showing [[Knoppix]] booting. The presence of [[Tux (mascot)|the penguin graphic]] indicates this is a framebuffer console as opposed to text mode console.]] | ||
The '''Linux console''' is a [[System console|system console]] internal to the [[Software:Linux kernel|Linux kernel]]. A system console is the device which receives all kernel messages and warnings and which allows logins in single user mode.<ref>{{cite web|url=https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/drivers/tty/Kconfig?id=HEAD|title=config VT_CONSOLE: Support for console on virtual terminal|publisher=Linus Torvalds|quote=The system console is the device which receives all kernel messages and warnings and which allows logins in single user mode.}}</ref> The Linux console provides a way for the kernel and other processes to send text output to the user, and to receive text input from the user. The user typically enters text with a [[Computer keyboard|computer keyboard]] and reads the output text on a [[Engineering:Computer monitor|computer monitor]]. The Linux kernel supports [[Virtual console|virtual console]]s – consoles that are logically separate, but which access the same physical keyboard and display.<ref>{{cite web|url=https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/drivers/tty/Kconfig?id=HEAD|title=config VT: Virtual terminal|publisher=Linus Torvalds|quote=If you say Y here, you will get support for terminal devices with display and keyboard devices. These are called "virtual" because you can run several virtual terminals (also called virtual consoles) on one physical terminal. This is rather useful, for example one virtual terminal can collect system messages and warnings, another one can be used for a text-mode user session, and a third could run an X session, all in parallel. Switching between virtual terminals is done with certain key combinations, usually Alt-<function key>.}}</ref> The Linux console (and Linux virtual consoles) are implemented by the VT (virtual terminal) subsystem of the Linux kernel, and do not rely on any [[User space|user space]] software.<ref name="deprecating"/> This is in contrast to a [[Terminal emulator|terminal emulator]], which is a user space process that emulates a terminal, and is typically used in a graphical display environment. | The '''Linux console''' is a [[System console|system console]] internal to the [[Software:Linux kernel|Linux kernel]]. A system console is the device which receives all kernel messages and warnings and which allows logins in single user mode.<ref>{{cite web|url=https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/drivers/tty/Kconfig?id=HEAD|title=config VT_CONSOLE: Support for console on virtual terminal|publisher=[[Biography:Linus Torvalds|Linus Torvalds]]|quote=The system console is the device which receives all kernel messages and warnings and which allows logins in single user mode.}}</ref> The Linux console provides a way for the kernel and other processes to send text output to the user, and to receive text input from the user. The user typically enters text with a [[Computer keyboard|computer keyboard]] and reads the output text on a [[Engineering:Computer monitor|computer monitor]]. The Linux kernel supports [[Virtual console|virtual console]]s – consoles that are logically separate, but which access the same physical keyboard and display.<ref>{{cite web|url=https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/drivers/tty/Kconfig?id=HEAD|title=config VT: Virtual terminal|publisher=[[Biography:Linus Torvalds|Linus Torvalds]]|quote=If you say Y here, you will get support for terminal devices with display and keyboard devices. These are called "virtual" because you can run several virtual terminals (also called virtual consoles) on one physical terminal. This is rather useful, for example one virtual terminal can collect system messages and warnings, another one can be used for a text-mode user session, and a third could run an X session, all in parallel. Switching between virtual terminals is done with certain key combinations, usually Alt-<function key>.}}</ref> The Linux console (and Linux virtual consoles) are implemented by the VT (virtual terminal) subsystem of the Linux kernel, and do not rely on any [[User space|user space]] software.<ref name="deprecating"/> This is in contrast to a [[Terminal emulator|terminal emulator]], which is a user space process that emulates a terminal, and is typically used in a graphical display environment. | ||
The Linux console was one of the first features of the kernel and was originally written by Linus Torvalds in 1991<ref>{{cite web|url=https://fosdem.org/2013/schedule/event/kmscon/|title=Replacing CONFIG_VT/Linux-Console|publisher=FOSDEM|date=2013-02-02|quote=CONFIG_VT is the kernel configuration option that enables virtual terminals in the kernel. Initially written by Linus himself, it has been around since 1991.}}</ref> (see [[History of Linux|history of Linux]]). There are two main implementations: [[Software:Linux framebuffer|framebuffer]] and [[Text mode|text mode]]. The framebuffer implementation is the default in modern [[Software:Linux distribution|Linux distribution]]s, and together with kernel mode setting, provides kernel-level support for display hardware and features such as showing graphics while the system is booting.<ref name="fbcon.txt">{{cite web|url=https://www.kernel.org/doc/Documentation/fb/fbcon.txt|title=The Framebuffer Console|publisher=[[Software:Kernel.org|kernel.org]]|quote=The framebuffer console (fbcon), as its name implies, is a text console running on top of the framebuffer device. It has the functionality of any standard text console driver, such as the VGA console, with the added features that can be attributed to the graphical nature of the framebuffer. In the x86 architecture, the framebuffer console is optional, and some even treat it as a toy. For other architectures, it is the only available display device, text or graphical. What are the features of fbcon? The framebuffer console supports high resolutions, varying font types, display rotation, primitive multihead, etc. Theoretically, multi-colored fonts, blending, aliasing, and any feature made available by the underlying graphics card are also possible.}}</ref> The legacy text mode implementation was used in PC-compatible systems with [[Color Graphics Adapter|CGA]], [[Enhanced Graphics Adapter|EGA]], [[IBM Monochrome Display Adapter|MDA]] and [[Video Graphics Array|VGA]] graphics cards. Non-[[X86|x86]] architectures used framebuffer mode because their graphics cards did not implement text mode.<ref name="fbcon.txt"/> The Linux console uses fixed-size bitmap, monospace fonts, usually defaulting to 8x16 pixels per character.<ref name="fbcon.txt"/> | The Linux console was one of the first features of the kernel and was originally written by [[Biography:Linus Torvalds|Linus Torvalds]] in 1991<ref>{{cite web|url=https://fosdem.org/2013/schedule/event/kmscon/|title=Replacing CONFIG_VT/Linux-Console|publisher=FOSDEM|date=2013-02-02|quote=CONFIG_VT is the kernel configuration option that enables virtual terminals in the kernel. Initially written by Linus himself, it has been around since 1991.}}</ref> (see [[History of Linux|history of Linux]]). There are two main implementations: [[Software:Linux framebuffer|framebuffer]] and [[Text mode|text mode]]. The framebuffer implementation is the default in modern [[Software:Linux distribution|Linux distribution]]s, and together with kernel mode setting, provides kernel-level support for display hardware and features such as showing graphics while the system is booting.<ref name="fbcon.txt">{{cite web|url=https://www.kernel.org/doc/Documentation/fb/fbcon.txt|title=The Framebuffer Console|publisher=[[Software:Kernel.org|kernel.org]]|quote=The framebuffer console (fbcon), as its name implies, is a text console running on top of the framebuffer device. It has the functionality of any standard text console driver, such as the VGA console, with the added features that can be attributed to the graphical nature of the framebuffer. In the x86 architecture, the framebuffer console is optional, and some even treat it as a toy. For other architectures, it is the only available display device, text or graphical. What are the features of fbcon? The framebuffer console supports high resolutions, varying font types, display rotation, primitive multihead, etc. Theoretically, multi-colored fonts, blending, aliasing, and any feature made available by the underlying graphics card are also possible.}}</ref> The legacy text mode implementation was used in PC-compatible systems with [[Color Graphics Adapter|CGA]], [[Enhanced Graphics Adapter|EGA]], [[IBM Monochrome Display Adapter|MDA]] and [[Video Graphics Array|VGA]] graphics cards. Non-[[X86|x86]] architectures used framebuffer mode because their graphics cards did not implement text mode.<ref name="fbcon.txt"/> The Linux console uses fixed-size bitmap, monospace fonts, usually defaulting to 8x16 pixels per character.<ref name="fbcon.txt"/> | ||
The Linux console is an optional kernel feature, and most embedded Linux systems do not enable it. These systems typically provide an alternative user interface (e.g. web based), or boot immediately into a [[Graphical user interface|graphical user interface]] and use this as the primary means of interacting with the user. Other implementations of the Linux console include the [[Braille]] console to support [[Refreshable braille display|refreshable Braille display]]s<ref name="braille-console.txt">{{cite web|url=https://www.kernel.org/doc/Documentation/braille-console.txt|title=Documentation/braille-console.txt|publisher=[[Software:Kernel.org|kernel.org]]|access-date=2014-07-04|archive-url=https://web.archive.org/web/20150906123942/https://www.kernel.org/doc/Documentation/braille-console.txt|archive-date=2015-09-06|url-status=dead}}</ref> and the [[Serial port|serial port]] console.<ref name="serial-console.txt">{{cite web|url=https://www.kernel.org/doc/Documentation/serial-console.txt|title=Documentation/serial-console.txt|publisher=[[Software:Kernel.org|kernel.org]]|access-date=2013-05-30|archive-url=https://web.archive.org/web/20130522013459/https://www.kernel.org/doc/Documentation/serial-console.txt|archive-date=2013-05-22|url-status=dead}}</ref> | The Linux console is an optional kernel feature, and most embedded Linux systems do not enable it. These systems typically provide an alternative user interface (e.g. web based), or boot immediately into a [[Graphical user interface|graphical user interface]] and use this as the primary means of interacting with the user. Other implementations of the Linux console include the [[Braille]] console to support [[Refreshable braille display|refreshable Braille display]]s<ref name="braille-console.txt">{{cite web|url=https://www.kernel.org/doc/Documentation/braille-console.txt|title=Documentation/braille-console.txt|publisher=[[Software:Kernel.org|kernel.org]]|access-date=2014-07-04|archive-url=https://web.archive.org/web/20150906123942/https://www.kernel.org/doc/Documentation/braille-console.txt|archive-date=2015-09-06|url-status=dead}}</ref> and the [[Serial port|serial port]] console.<ref name="serial-console.txt">{{cite web|url=https://www.kernel.org/doc/Documentation/serial-console.txt|title=Documentation/serial-console.txt|publisher=[[Software:Kernel.org|kernel.org]]|access-date=2013-05-30|archive-url=https://web.archive.org/web/20130522013459/https://www.kernel.org/doc/Documentation/serial-console.txt|archive-date=2013-05-22|url-status=dead}}</ref> | ||
==Purpose== | ==Purpose== | ||
{{See also|Linux startup process}} | |||
The Linux console provides a way for the kernel and other processes to output text-based messages to the user, and to receive text-based input from the user. In Linux, several devices can be used as system console: a virtual terminal,<ref>{{cite web|title=CONFIG_VT_CONSOLE: Support for console on virtual terminal|url=http://cateee.net/lkddb/web-lkddb/VT_CONSOLE.html|quote=The system console is the device which receives all kernel messages and warnings and which allows logins in single user mode. If you answer Y here, a virtual terminal (the device used to interact with a physical terminal) can be used as system console.}}</ref> serial port,<ref>{{cite web|title=CONFIG_SERIAL_CONSOLE: Support for console on serial port|url=http://cateee.net/lkddb/web-lkddb/SERIAL_CONSOLE.html|quote=If you say Y here, it will be possible to use a serial port as the system console (the system console is the device which receives all kernel messages and warnings and which allows logins in single user mode). This could be useful if some terminal or printer is connected to that serial port.}}</ref> USB serial port,<ref>{{cite web|title=CONFIG_USB_SERIAL_CONSOLE: USB Serial Console device support|url=http://cateee.net/lkddb/web-lkddb/USB_SERIAL_CONSOLE.html|quote=If you say Y here, it will be possible to use a USB to serial converter port as the system console (the system console is the device which receives all kernel messages and warnings and which allows logins in single user mode). This could be useful if some terminal or printer is connected to that serial port.}}</ref> VGA in text-mode,<ref>{{cite web|title=CONFIG_VGA_CONSOLE: VGA text console|url=http://cateee.net/lkddb/web-lkddb/VGA_CONSOLE.html|quote=Saying Y here will allow you to use Linux in text mode through a display that complies with the generic VGA standard. Virtually everyone wants that.}}</ref> framebuffer.<ref>{{cite web|title=CONFIG_FRAMEBUFFER_CONSOLE: Framebuffer Console support|url=http://cateee.net/lkddb/web-lkddb/FRAMEBUFFER_CONSOLE.html}}</ref> Some modern Linux-based systems have deprecated kernel based text-mode input and output, and instead show a graphical logo or [[Progress bar|progress bar]] while the system is booting, followed by the immediate start of a graphical user interface (e.g. the [[Software:X.Org Server|X.Org Server]] on desktop distributions, or SurfaceFlinger on Android). | The Linux console provides a way for the kernel and other processes to output text-based messages to the user, and to receive text-based input from the user. In Linux, several devices can be used as system console: a virtual terminal,<ref>{{cite web|title=CONFIG_VT_CONSOLE: Support for console on virtual terminal|url=http://cateee.net/lkddb/web-lkddb/VT_CONSOLE.html|quote=The system console is the device which receives all kernel messages and warnings and which allows logins in single user mode. If you answer Y here, a virtual terminal (the device used to interact with a physical terminal) can be used as system console.}}</ref> serial port,<ref>{{cite web|title=CONFIG_SERIAL_CONSOLE: Support for console on serial port|url=http://cateee.net/lkddb/web-lkddb/SERIAL_CONSOLE.html|quote=If you say Y here, it will be possible to use a serial port as the system console (the system console is the device which receives all kernel messages and warnings and which allows logins in single user mode). This could be useful if some terminal or printer is connected to that serial port.}}</ref> USB serial port,<ref>{{cite web|title=CONFIG_USB_SERIAL_CONSOLE: USB Serial Console device support|url=http://cateee.net/lkddb/web-lkddb/USB_SERIAL_CONSOLE.html|quote=If you say Y here, it will be possible to use a USB to serial converter port as the system console (the system console is the device which receives all kernel messages and warnings and which allows logins in single user mode). This could be useful if some terminal or printer is connected to that serial port.}}</ref> VGA in text-mode,<ref>{{cite web|title=CONFIG_VGA_CONSOLE: VGA text console|url=http://cateee.net/lkddb/web-lkddb/VGA_CONSOLE.html|quote=Saying Y here will allow you to use Linux in text mode through a display that complies with the generic VGA standard. Virtually everyone wants that.}}</ref> framebuffer.<ref>{{cite web|title=CONFIG_FRAMEBUFFER_CONSOLE: Framebuffer Console support|url=http://cateee.net/lkddb/web-lkddb/FRAMEBUFFER_CONSOLE.html}}</ref> Some modern Linux-based systems have deprecated kernel based text-mode input and output, and instead show a graphical logo or [[Progress bar|progress bar]] while the system is booting, followed by the immediate start of a graphical user interface (e.g. the [[Software:X.Org Server|X.Org Server]] on desktop distributions, or SurfaceFlinger on Android). | ||
During kernel boot, the console is commonly used to display the boot log of the kernel. The boot log includes information about detected hardware, and updates on the status of the boot procedure. At this point in time, the kernel is the only software running, and hence logging via user-space (e.g. [[ | During kernel boot, the console is commonly used to display the boot log of the kernel. The boot log includes information about detected hardware, and updates on the status of the boot procedure. At this point in time, the kernel is the only software running, and hence logging via user-space (e.g. [[Syslog|syslog]]) is not possible, so the console provides a convenient place to output this information. Once the kernel has finished booting, it runs the [[Software:Init|init]] process (also sending output to the console), which handles booting of the rest of the system including starting any background [[Daemon (computing)|daemons]]. | ||
After the ''init'' boot process is complete, the console will be used to [[Engineering:Multiplexing|multiplex]] multiple [[Engineering:Virtual terminal|virtual terminal]]s (accessible by pressing Ctrl-Alt-F1, Ctrl-Alt-F2 etc., Ctrl-Alt-LeftArrow, Ctrl-Alt-RightArrow, or using ''chvt''<ref>{{cite web|url=http://linux.die.net/man/1/chvt|title=chvt(1) - Linux man page: chvt - change foreground virtual terminal}}</ref>). On each ''virtual terminal'', a [[Software:Getty (Unix)|getty]] process is run, which in turn runs ''/bin/login'' to authenticate a user. After authentication, a command shell will be run. Virtual terminals, like the console, are supported at the Linux kernel level.<ref>{{cite web|url=http://linux.die.net/man/4/console|title=console(4) – Linux man page: console – console terminal and virtual consoles|quote=A Linux system has up to 63 virtual consoles}}</ref> | After the ''init'' boot process is complete, the console will be used to [[Engineering:Multiplexing|multiplex]] multiple [[Engineering:Virtual terminal|virtual terminal]]s (accessible by pressing Ctrl-Alt-F1, Ctrl-Alt-F2 etc., Ctrl-Alt-LeftArrow, Ctrl-Alt-RightArrow, or using ''chvt''<ref>{{cite web|url=http://linux.die.net/man/1/chvt|title=chvt(1) - Linux man page: chvt - change foreground virtual terminal}}</ref>). On each ''virtual terminal'', a [[Software:Getty (Unix)|getty]] process is run, which in turn runs ''/bin/login'' to authenticate a user. After authentication, a command shell will be run. Virtual terminals, like the console, are supported at the Linux kernel level.<ref>{{cite web|url=http://linux.die.net/man/4/console|title=console(4) – Linux man page: console – console terminal and virtual consoles|quote=A Linux system has up to 63 virtual consoles}}</ref> | ||
| Line 28: | Line 29: | ||
==Text mode console== | ==Text mode console== | ||
{{See also|VGA-compatible text mode|Text mode}} | |||
The [[Text mode|text mode]] implementation is used on PC-based systems with a legacy CGA/EGA/MDA/VGA video card that implements text-based video modes. In text mode, the kernel sends a 2D array of characters to the video card, and the video card converts the characters to pixels for display. | The [[Text mode|text mode]] implementation is used on PC-based systems with a legacy CGA/EGA/MDA/VGA video card that implements text-based video modes. In text mode, the kernel sends a 2D array of characters to the video card, and the video card converts the characters to pixels for display. | ||
| Line 36: | Line 38: | ||
The Linux kernel ({{mono|keyboard.c}} driver) has almost complete support for keyboard input (keyboard layouts), but it remains a bit inconsistent because it interacts badly with different character sets. Layouts are loaded by the {{mono|'''loadkeys'''}} utility. | The Linux kernel ({{mono|keyboard.c}} driver) has almost complete support for keyboard input (keyboard layouts), but it remains a bit inconsistent because it interacts badly with different character sets. Layouts are loaded by the {{mono|'''loadkeys'''}} utility. | ||
These two utilities and corresponding data files are packed in '''Linux Console Tools''' | These two utilities and corresponding data files are packed in '''Linux Console Tools''' https://lct.sourceforge.net/ shipped with many [[Software:Linux distribution|Linux distribution]]s. | ||
Efforts on the internationalization of Linux at the kernel level started as early as in 1994 by [[Biography:Markus Kuhn (computer scientist)|Markus Kuhn]] and Andries Brouwer. | Efforts on the internationalization of Linux at the kernel level started as early as in 1994 by [[Biography:Markus Kuhn (computer scientist)|Markus Kuhn]] and Andries Brouwer. | ||
| Line 102: | Line 104: | ||
| {{Partial|Application dependent}} | | {{Partial|Application dependent}} | ||
| {{Partial|System and application dependent}} | | {{Partial|System and application dependent}} | ||
|} | |} | ||
| Line 121: | Line 118: | ||
==Linux serial port console== | ==Linux serial port console== | ||
Linux serial console is a console implementation via [[Serial port|serial port]], enabled by option | The Linux serial console is a console implementation via [[Serial port|serial port]], enabled by the CONFIG_SERIAL_CONSOLE option in the kernel configuration. It may be used in some [[Embedded system|embedded system]]s, and on servers, where direct interaction with an [[Computer operator|operator]] is not expected. The serial console allows the same access to the system as framebuffer mode, but usually at a slower speed due to the limited bandwidth of the [[RS-232]] interface. A serial console is often used during development of software for embedded systems, and is sometimes left accessible via a debug port. | ||
==Control characters== | ==Control characters== | ||
| Line 129: | Line 126: | ||
! Control character !! ASCII name !! Description | ! Control character !! ASCII name !! Description | ||
|- | |- | ||
| ^G || BEL || Bell sound | | {{mono|^G}} || BEL || Bell sound | ||
|- | |- | ||
| ^H || BS || Backspace | | {{mono|^H}} || BS || Backspace | ||
|- | |- | ||
| ^I || HT || Horizontal tab | | {{mono|^I}} || HT || Horizontal tab | ||
|- | |- | ||
| ^J || LF || Line feed | | {{mono|^J}} || LF || Line feed | ||
|- | |- | ||
| ^K || VT || Vertical tab | | {{mono|^K}} || VT || Vertical tab | ||
|- | |- | ||
| ^L || FF || Form feed | | {{mono|^L}} || FF || Form feed | ||
|- | |- | ||
| ^M || CR || Carriage return | | {{mono|^M}} || CR || Carriage return | ||
|- | |- | ||
| ^N || SO || Shift out | | {{mono|^N}} || SO || Shift out | ||
|- | |- | ||
| ^O || SI || Shift in | | {{mono|^O}} || SI || Shift in | ||
|- | |- | ||
| ^X || CAN || Cancel escape sequence | | {{mono|^X}} || CAN || Cancel escape sequence | ||
|- | |- | ||
| ^Z || SUB || Cancel escape sequence | | {{mono|^Z}} || SUB || Cancel escape sequence | ||
|- | |- | ||
| ^[ || ESC || Escape / begin escape sequence | | {{mono|^[}} || ESC || Escape / begin escape sequence | ||
|- | |- | ||
| ^? || DEL || Nothing | | {{mono|^?}} || DEL || Nothing | ||
|- | |- | ||
| ALT-^[ || n/a || Start command sequence | | {{mono|ALT-^[}} || {{n/a}} || Start command sequence | ||
|} | |} | ||
| Line 162: | Line 159: | ||
! Control sequence !! Description | ! Control sequence !! Description | ||
|- | |- | ||
| ^[M || Reverse line feed | | {{mono|^[M}} || Reverse line feed | ||
|- | |- | ||
| ^[D || Line feed | | {{mono|^[D}} || Line feed | ||
|- | |- | ||
| ^[E || Carriage return and line feed | | {{mono|^[E}} || Carriage return and line feed | ||
|- | |- | ||
| ^[H || Set tab stop | | {{mono|^[H}} || Set tab stop | ||
|- | |- | ||
| ^[7 || Store cursor | | {{mono|^[7}} || Store cursor | ||
|- | |- | ||
| ^[8 || Restore cursor | | {{mono|^[8}} || Restore cursor | ||
|- | |- | ||
| ^[> || Switch keypad to numeric mode | | {{mono|^[>}} || Switch keypad to numeric mode | ||
|- | |- | ||
| ^[= || Switch keypad to application mode | | {{mono|1=^[=}} || Switch keypad to application mode | ||
|- | |- | ||
| ^[c || Reset terminal settings | | {{mono|^[c}} || Reset terminal settings | ||
|- | |- | ||
| ^[Z || Print terminal ID | | {{mono|^[Z}} || Print terminal ID | ||
|- | |- | ||
|} | |} | ||
Latest revision as of 11:05, 23 May 2026


The Linux console is a system console internal to the Linux kernel. A system console is the device which receives all kernel messages and warnings and which allows logins in single user mode.[1] The Linux console provides a way for the kernel and other processes to send text output to the user, and to receive text input from the user. The user typically enters text with a computer keyboard and reads the output text on a computer monitor. The Linux kernel supports virtual consoles – consoles that are logically separate, but which access the same physical keyboard and display.[2] The Linux console (and Linux virtual consoles) are implemented by the VT (virtual terminal) subsystem of the Linux kernel, and do not rely on any user space software.[3] This is in contrast to a terminal emulator, which is a user space process that emulates a terminal, and is typically used in a graphical display environment.
The Linux console was one of the first features of the kernel and was originally written by Linus Torvalds in 1991[4] (see history of Linux). There are two main implementations: framebuffer and text mode. The framebuffer implementation is the default in modern Linux distributions, and together with kernel mode setting, provides kernel-level support for display hardware and features such as showing graphics while the system is booting.[5] The legacy text mode implementation was used in PC-compatible systems with CGA, EGA, MDA and VGA graphics cards. Non-x86 architectures used framebuffer mode because their graphics cards did not implement text mode.[5] The Linux console uses fixed-size bitmap, monospace fonts, usually defaulting to 8x16 pixels per character.[5]
The Linux console is an optional kernel feature, and most embedded Linux systems do not enable it. These systems typically provide an alternative user interface (e.g. web based), or boot immediately into a graphical user interface and use this as the primary means of interacting with the user. Other implementations of the Linux console include the Braille console to support refreshable Braille displays[6] and the serial port console.[7]
Purpose
The Linux console provides a way for the kernel and other processes to output text-based messages to the user, and to receive text-based input from the user. In Linux, several devices can be used as system console: a virtual terminal,[8] serial port,[9] USB serial port,[10] VGA in text-mode,[11] framebuffer.[12] Some modern Linux-based systems have deprecated kernel based text-mode input and output, and instead show a graphical logo or progress bar while the system is booting, followed by the immediate start of a graphical user interface (e.g. the X.Org Server on desktop distributions, or SurfaceFlinger on Android).
During kernel boot, the console is commonly used to display the boot log of the kernel. The boot log includes information about detected hardware, and updates on the status of the boot procedure. At this point in time, the kernel is the only software running, and hence logging via user-space (e.g. syslog) is not possible, so the console provides a convenient place to output this information. Once the kernel has finished booting, it runs the init process (also sending output to the console), which handles booting of the rest of the system including starting any background daemons.
After the init boot process is complete, the console will be used to multiplex multiple virtual terminals (accessible by pressing Ctrl-Alt-F1, Ctrl-Alt-F2 etc., Ctrl-Alt-LeftArrow, Ctrl-Alt-RightArrow, or using chvt[13]). On each virtual terminal, a getty process is run, which in turn runs /bin/login to authenticate a user. After authentication, a command shell will be run. Virtual terminals, like the console, are supported at the Linux kernel level.[14]
The Linux console implements a terminal type of "linux" and the escape sequences it uses are in the console_codes man page.[15]
Virtual consoles
Virtual consoles allow the storage of multiple text buffers, enabling different console programs to run simultaneously but interact with the user in different contexts. From the user's point of view, this creates the illusion of several independent consoles.
Each virtual console can have its own character set and keyboard layout. Linux 2.6 introduced the ability to load a different font for each virtual console (kernel versions predating 2.6 change the font only on demand).
Text mode console
The text mode implementation is used on PC-based systems with a legacy CGA/EGA/MDA/VGA video card that implements text-based video modes. In text mode, the kernel sends a 2D array of characters to the video card, and the video card converts the characters to pixels for display.
Font, character set and keyboard layout
The text buffer is a part of VGA memory which describes the content of a text screen in terms of code points and character attributes. Code points in the text buffer and font are generally not the same as encoding used in text terminal semantics to put characters on the screen. The set of glyphs on the screen is determined by the current font. The text screen is handled by console.c and consolemap.c drivers. There is a utility for altering fonts and terminal encodings called consolechars.
The Linux kernel (keyboard.c driver) has almost complete support for keyboard input (keyboard layouts), but it remains a bit inconsistent because it interacts badly with different character sets. Layouts are loaded by the loadkeys utility.
These two utilities and corresponding data files are packed in Linux Console Tools https://lct.sourceforge.net/ shipped with many Linux distributions.
Efforts on the internationalization of Linux at the kernel level started as early as in 1994 by Markus Kuhn and Andries Brouwer.
Text modes
The Linux console is capable of supporting any VGA-style text mode, but the kernel itself has very limited means to set these modes up. SVGATextMode helps to enable more complex text modes than the standard EGA and VGA modes. It is fully compatible with Console Tools, but has some conflicts with dosemu, SVGAlib and display servers.
Currently, there is no support for different modes on different virtual consoles.
Comparison to Windows and DOS
Microsoft Windows (of any version) does not have a fully functional support of the console[when?]. The comparable feature there, but for application software only, is the Win32 console.
| Feature | Linux | Windows | DOS |
|---|---|---|---|
| VGA text attributes | Yes | Yes | Yes |
| Custom fonts | Possible | Possible | Possible |
| Character set | 512 glyphs max. (on VGA text), any code page or UTF-8 |
223 or 256 characters (depends on access method), any code page, or Unicode[n 1] | |
| Run-time character set switching | Possible[n 2] | Impossible[n 1] | Depends on PoV |
| Terminal emulation | Yes, ANSI-compatible (TERM=linux) |
Yes, since Windows 10 "Threshold 2"[16] | Yes, ANSI (with ANSI.SYS) |
| Run-time switching between text mode and GUI | With kernel mode setting, hindered by some hardware (i.e. proprietary drivers) [n 3] | No way to get back to GUI | Application dependent |
| Run-time changing numbers of rows and columns | Possible | Possible | Application dependent |
| Switching between applications | Possible | Possible | Limited (some terminate-and-stay-resident programs may be activated) |
| Non-standard modes | Possible | Impossible | Possible |
| Mouse support | Yes (with gpm or similar) | Application dependent | System and application dependent |
- a b Unicode supported since Windows NT based systems, which allow to switch code pages and use Unicode, but only in window mode. Also, NT systems use own text buffer format incompatible with VGA, which produces an overhead in hardware text modes. No Unicode support in non-NT versions of Windows
- a As non-ASCII keyboard layout should be reloaded because of flawed implementation.
- a Kernel mode settings in recent kernels make this more practical for some video hardware.
Linux framebuffer console
The Linux framebuffer (fbdev) is a graphic hardware-independent abstraction layer, which was originally implemented to allow the Linux kernel to emulate a text console on systems such as the Apple Macintosh that do not have a text-mode display. Now it offers a kernel space text mode emulation on any platform. Its advantage over (currently unmaintained) SVGATextMode is a reliance and better hardware compatibility. It also permits to overcome all technical restrictions of VGA text modes.
A Linux framebuffer console differs from a VGA one only in ways of drawing characters. The processing of keyboard events and virtual consoles’ support are exactly the same.
Linux serial port console
The Linux serial console is a console implementation via serial port, enabled by the CONFIG_SERIAL_CONSOLE option in the kernel configuration. It may be used in some embedded systems, and on servers, where direct interaction with an operator is not expected. The serial console allows the same access to the system as framebuffer mode, but usually at a slower speed due to the limited bandwidth of the RS-232 interface. A serial console is often used during development of software for embedded systems, and is sometimes left accessible via a debug port.
Control characters
The console responds to a number of control characters:[17]
| Control character | ASCII name | Description |
|---|---|---|
| ^G | BEL | Bell sound |
| ^H | BS | Backspace |
| ^I | HT | Horizontal tab |
| ^J | LF | Line feed |
| ^K | VT | Vertical tab |
| ^L | FF | Form feed |
| ^M | CR | Carriage return |
| ^N | SO | Shift out |
| ^O | SI | Shift in |
| ^X | CAN | Cancel escape sequence |
| ^Z | SUB | Cancel escape sequence |
| ^[ | ESC | Escape / begin escape sequence |
| ^? | DEL | Nothing |
| ALT-^[ | N/A | Start command sequence |
| Control sequence | Description |
|---|---|
| ^[M | Reverse line feed |
| ^[D | Line feed |
| ^[E | Carriage return and line feed |
| ^[H | Set tab stop |
| ^[7 | Store cursor |
| ^[8 | Restore cursor |
| ^[> | Switch keypad to numeric mode |
| ^[= | Switch keypad to application mode |
| ^[c | Reset terminal settings |
| ^[Z | Print terminal ID |
For ^[ press the Escape key.
The console also supports extended escape sequences, ANSI CSI Mode sequences, and DEC Private Mode sequences.[15][17] These extended sequences can control colors, visual effects like blinking, underline, intensity and inverse video, bell tone frequency and duration, VESA screen blanking interval. Aside from the textual blanking, there is no known way to place the VGA adapter into standby.
Future plans
The Kmscon projects aims to create a modern user-space replacement for the Linux console.[18][19] Development priorities include support for multi-monitor setups, Unicode font rendering with Pango, XKB keyboard handling, and GPU OpenGL acceleration.[20] Complaints about the current kernel implementation include "that it's a user-interface in kernel-space, the code is poorly maintained, handles keyboards badly, produces bad font rendering, misses out on mode-setting and multi-head support, contains no multi-seat awareness, and only has limited hot-plugging handling, limited to VT102 compliance."[3]
List of /dev/ entries related to the console
| Name | Major | Minor | Description |
|---|---|---|---|
| /dev/tty0 | c 4 | 0 | "current console" |
| /dev/tty1 ... /dev/tty63 |
c 4 | 1 ... 63 |
virtual consoles (keyboard controlled) |
| /dev/ttyS0 ... |
c 4 | 64 ... |
Serial ports, suitable for system console |
| /dev/vcs | c 7 | 0 | Virtual Console Screen /dev/vcs is the contents of the current virtual screen. |
| /dev/vcs1 ... /dev/vcs63 |
c 7 | 1 ... 63 |
The text (the character pointer table) of a virtual screen. |
| /dev/vcsa1 ... /dev/vcsa63 |
c 7 | 129 ... 191 |
Virtual Console Screen with Attributes Full image of a virtual text buffer; first 4 bytes contain numbers of rows, columns and cursor position |
See also
References
- ↑ "config VT_CONSOLE: Support for console on virtual terminal". Linus Torvalds. https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/drivers/tty/Kconfig?id=HEAD. "The system console is the device which receives all kernel messages and warnings and which allows logins in single user mode."
- ↑ "config VT: Virtual terminal". Linus Torvalds. https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/drivers/tty/Kconfig?id=HEAD. "If you say Y here, you will get support for terminal devices with display and keyboard devices. These are called "virtual" because you can run several virtual terminals (also called virtual consoles) on one physical terminal. This is rather useful, for example one virtual terminal can collect system messages and warnings, another one can be used for a text-mode user session, and a third could run an X session, all in parallel. Switching between virtual terminals is done with certain key combinations, usually Alt-<function key>."
- ↑ 3.0 3.1 David Herrmann (2012-08-12). "Deprecating CONFIG_VT". http://dvdhrm.wordpress.com/2012/08/12/killing-off-config_vt/.
- ↑ "Replacing CONFIG_VT/Linux-Console". FOSDEM. 2013-02-02. https://fosdem.org/2013/schedule/event/kmscon/. "CONFIG_VT is the kernel configuration option that enables virtual terminals in the kernel. Initially written by Linus himself, it has been around since 1991."
- ↑ 5.0 5.1 5.2 "The Framebuffer Console". kernel.org. https://www.kernel.org/doc/Documentation/fb/fbcon.txt. "The framebuffer console (fbcon), as its name implies, is a text console running on top of the framebuffer device. It has the functionality of any standard text console driver, such as the VGA console, with the added features that can be attributed to the graphical nature of the framebuffer. In the x86 architecture, the framebuffer console is optional, and some even treat it as a toy. For other architectures, it is the only available display device, text or graphical. What are the features of fbcon? The framebuffer console supports high resolutions, varying font types, display rotation, primitive multihead, etc. Theoretically, multi-colored fonts, blending, aliasing, and any feature made available by the underlying graphics card are also possible."
- ↑ "Documentation/braille-console.txt". kernel.org. https://www.kernel.org/doc/Documentation/braille-console.txt.
- ↑ "Documentation/serial-console.txt". kernel.org. https://www.kernel.org/doc/Documentation/serial-console.txt.
- ↑ "CONFIG_VT_CONSOLE: Support for console on virtual terminal". http://cateee.net/lkddb/web-lkddb/VT_CONSOLE.html. "The system console is the device which receives all kernel messages and warnings and which allows logins in single user mode. If you answer Y here, a virtual terminal (the device used to interact with a physical terminal) can be used as system console."
- ↑ "CONFIG_SERIAL_CONSOLE: Support for console on serial port". http://cateee.net/lkddb/web-lkddb/SERIAL_CONSOLE.html. "If you say Y here, it will be possible to use a serial port as the system console (the system console is the device which receives all kernel messages and warnings and which allows logins in single user mode). This could be useful if some terminal or printer is connected to that serial port."
- ↑ "CONFIG_USB_SERIAL_CONSOLE: USB Serial Console device support". http://cateee.net/lkddb/web-lkddb/USB_SERIAL_CONSOLE.html. "If you say Y here, it will be possible to use a USB to serial converter port as the system console (the system console is the device which receives all kernel messages and warnings and which allows logins in single user mode). This could be useful if some terminal or printer is connected to that serial port."
- ↑ "CONFIG_VGA_CONSOLE: VGA text console". http://cateee.net/lkddb/web-lkddb/VGA_CONSOLE.html. "Saying Y here will allow you to use Linux in text mode through a display that complies with the generic VGA standard. Virtually everyone wants that."
- ↑ "CONFIG_FRAMEBUFFER_CONSOLE: Framebuffer Console support". http://cateee.net/lkddb/web-lkddb/FRAMEBUFFER_CONSOLE.html.
- ↑ "chvt(1) - Linux man page: chvt - change foreground virtual terminal". http://linux.die.net/man/1/chvt.
- ↑ "console(4) – Linux man page: console – console terminal and virtual consoles". http://linux.die.net/man/4/console. "A Linux system has up to 63 virtual consoles"
- ↑ 15.0 15.1 "console_codes(4) – Linux man page: console_codes – Linux console escape and control sequences". http://linux.die.net/man/4/console_codes.
- ↑ "Windows 10 TH2 (v1511) Console Host Enhancements". 2016-02-04. http://www.nivot.org/blog/post/2016/02/04/Windows-10-TH2-(v1511)-Console-Host-Enhancements.
- ↑ 17.0 17.1 Michael K. Johnson and Erik W. Troan (2005). Linux Application Development – The Linux Console. ASCII books. ISBN 0321563220. http://www.ladweb.net/. Retrieved 2013-09-03.
- ↑ David Herrmann (2012-08-11). "KMSCON: Linux KMS/DRM based Virtual Console". http://dvdhrm.wordpress.com/2012/08/11/kmscon-linux-kmsdrm-based-virtual-console/.
- ↑ Michael Larabel (2013-03-28). "KMSCON: A DRM-Based Terminal Emulator". Phoronix. https://www.phoronix.com/scan.php?page=news_item&px=MTA3ODE. "Announced yesterday was the release of kmscon, a terminal emulator for Linux that's similar to what's offered inside the kernel, but instead it's in user-space and relies upon the kernel's DRM interfaces as well as Mesa."
- ↑ Michael Larabel (2013-02-08). "The Linux Kernel Console Is Being Killed Off". Phoronix. https://www.phoronix.com/scan.php?page=news_item&px=MTI5Njc. "CONFIG_VT has been part of the Linux kernel going back to the early 90s but hasn't really advanced much in that time. David Herrmann, a developer that got going on this new initiative as a student part of Google Summer of Code, wants a new solution that's built with multi-seat and multiple monitors in mind, incorporates Unicode font rendering, XKB-like keyboard handling, graphics hardware acceleration, VT220-VT510 compatibility, and other features."
