Jump to content

Linux console: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
clarify, refs
more stuff
Line 1: Line 1:
{{Refimprove|date=March 2010}}
[[Image:Knoppix-3.8-boot.png|thumb|right|Framebuffer console showing [[Knoppix]] booting. The presence of the penguin graphic indicates this is a framebuffer console as opposed to text mode console. ]]
[[Image:Knoppix-3.8-boot.png|thumb|right|Framebuffer console showing [[Knoppix]] booting. The presence of the penguin graphic indicates this is a framebuffer console as opposed to text mode console. ]]

The '''Linux console''' is a [[system console]] supported by the [[Linux kernel]]. The Linux console was one of the first features of the kernel, developed as early as 1991 (see [[history of Linux]]). There are two main implementations: [[Linux framebuffer|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.<ref name="fbcon.txt">{{cite web|url=https://www.kernel.org/doc/Documentation/fb/fbcon.txt|title=The Framebuffer Console|publisher=[[kernel.org]]|quote=
The '''Linux console''' is a [[system console]] supported by the [[Linux kernel]]. 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 console (and Linux virtual consoles) are a feature of the Linux kernel, and do not rely on any [[user space]] software. 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, developed as early as 1991 (see [[history of Linux]]). There are two main implementations: [[Linux framebuffer|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.<ref name="fbcon.txt">{{cite web|url=https://www.kernel.org/doc/Documentation/fb/fbcon.txt|title=The Framebuffer Console|publisher=[[kernel.org]]|quote=
The framebuffer console (fbcon), as its name implies, is a text
The framebuffer console (fbcon), as its name implies, is a text
console running on top of the framebuffer device. It has the functionality of
console running on top of the framebuffer device. It has the functionality of
Line 16: Line 18:
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 architectures used framebuffer mode as their graphics cards did not implement text mode.<ref name="fbcon.txt"/> The Linux console uses fixed-size [[bitmap fonts|bitmap]], [[monospace font]]s, usually defaulting to 8x16 pixels per character.<ref name="fbcon.txt"/>
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 architectures used framebuffer mode as their graphics cards did not implement text mode.<ref name="fbcon.txt"/> The Linux console uses fixed-size [[bitmap fonts|bitmap]], [[monospace font]]s, usually defaulting to 8x16 pixels per character.<ref name="fbcon.txt"/>


The Linux console is an optional kernel feature, and many modern systems do not enable it. These systems typically 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<ref name="braille-console.txt">{{cite web|url=http://www.mjmwired.net/kernel/Documentation/braille-console.txt|title=Linux Braille Console|publisher=[[kernel.org]]}}</ref> and the [[serial port]] console.<ref name="serial-console.txt">{{cite web|url=https://www.kernel.org/doc/Documentation/serial-console.txt|title=Linux Serial Console|publisher=[[kernel.org]]}}</ref>
Other implementations of the Linux console include the [[Braille]] console<ref name="braille-console.txt">{{cite web|url=http://www.mjmwired.net/kernel/Documentation/braille-console.txt|title=Linux Braille Console|publisher=[[kernel.org]]}}</ref> and the [[serial port]] console.<ref name="serial-console.txt">{{cite web|url=https://www.kernel.org/doc/Documentation/serial-console.txt|title=Linux Serial Console|publisher=[[kernel.org]]}}</ref>


== Purpose ==
== Purpose ==
{{seealso|Linux startup process}}
{{Expand section|date=March 2010}}

The Linux console is intended to run usual [[text user interface]] applications, and also to show some kernel messages (considered as urgent or important).
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. 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 [[Daemon (computing)|daemons]].

After the ''init'' boot process is complete, the console will be used to [[multiplex]] multiple [[virtual terminals]] (accessible by pressing Alt-F1, Alt-F2 etc. 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 [[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>

The Linux console implements a [[Terminal capabilities|terminal type]] of "Linux" and the escape sequences it uses are in the ''console_codes'' [[man page]].<ref>{{cite web|url=http://linux.die.net/man/4/console_codes|title=console_codes(4) - Linux man page: console_codes - Linux console escape and control sequences}}</ref>


== VGA text mode implementation of the console ==
== Text mode console ==
{{See also|VGA-compatible text mode|Text mode}}
{{See also|VGA-compatible text mode|Text mode}}


The [[text mode]] implementation is used on systems with a legacy [[Video Graphics Array|VGA graphics card]]. In text mode, the kernel sends a 2D array of characters to the graphics card, and the graphics card converts the characters to pixels for display.
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 ===
=== Font, character set and keyboard layout ===
Line 35: Line 45:


Efforts on the [[internationalization]] of Linux at the kernel level started as early as in 1994 by [[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 [[Markus Kuhn (computer scientist)|Markus Kuhn]] and [[Andries Brouwer]].

=== Virtual consoles ===
{{Main|Virtual console}}
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 modes ===
=== Text modes ===
Line 109: Line 112:
#{{note label|comparison|n 3|a}} [http://kerneltrap.org/node/8242 Kernel mode settings] in recent kernels make this more practical for some video hardware.
#{{note label|comparison|n 3|a}} [http://kerneltrap.org/node/8242 Kernel mode settings] in recent kernels make this more practical for some video hardware.


== Linux framebuffer ==
== Linux framebuffer console ==
{{Main|Linux framebuffer}}
{{Main|Linux framebuffer}}
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 overpass all [[VGA-compatible text mode#General restrictions|technical restrictions of VGA text modes]].
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 overpass all [[VGA-compatible text mode#General restrictions|technical restrictions of VGA text modes]].
Line 115: Line 118:
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.
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.


== Unusual implementations ==
== Linux serial port console ==
Linux serial console is a console implementation via [[serial port]]. It may be used in some [[embedded system]]s, and on [[server computer|servers]], where a direct interaction with [[computer operator|operator]] is not expected. The serial console allows the same mode of access for the system, but usually at a slower speed due to the small bandwidth of [[RS-232]].
Linux serial console is a console implementation via [[serial port]]. It may be used in some [[embedded system]]s, and on [[server computer|servers]], where a direct interaction with [[computer operator|operator]] is not expected. The serial console allows the same mode of access for the system, but usually at a slower speed due to the small bandwidth of [[RS-232]]. A serial console is often used during development of software for embedded systems, and is sometimes left accessible via a [[debug port]].


== Virtual consoles ==
There is also a console implementation via [[Bluetooth]].<!-- is it logically the same thing as a serial console but via /dev/rfcomm? I don't know this topic reliably. --Incnis Mrsi -->
{{Main|Virtual console}}
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).


== List of /dev/ entries related to the console ==
== List of /dev/ entries related to the console ==
Line 155: Line 163:
==References==
==References==
<references />
<references />

== See also ==
* [[xterm]]


{{Linux}}
{{Linux}}

Revision as of 18:29, 30 May 2013

Framebuffer console showing Knoppix booting. The presence of the penguin graphic indicates this is a framebuffer console as opposed to text mode console.

The Linux console is a system console supported by the Linux kernel. 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 console (and Linux virtual consoles) are a feature of the Linux kernel, and do not rely on any user space software. 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, developed as early as 1991 (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.[1] 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 as their graphics cards did not implement text mode.[1] The Linux console uses fixed-size bitmap, monospace fonts, usually defaulting to 8x16 pixels per character.[1]

The Linux console is an optional kernel feature, and many modern systems do not enable it. These systems typically 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[2] and the serial port console.[3]

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. 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 Alt-F1, Alt-F2 etc. or using chvt[4]). 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.[5]

The Linux console implements a terminal type of "Linux" and the escape sequences it uses are in the console_codes man page.[6]

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 http://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 X 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. 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, no Unicode[n 1]
Run-time character set switching Possible[n 2] Impossible[n 1] Depends on PoV
Terminal emulation Yes, ANSI-compatible
(TERM=linux)
No Yes, ANSI
(with ANSI.SYS)
Run-time switching between text mode and GUI Technically possible, but usually impractical[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 TSRs may be activated)
Non-standard modes Possible Impossible Possible
Mouse support Yes (with gpm or so) Application dependent System and application dependent
  1. a b As for Windows 9x. Windows NT based systems 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.
  2. a As non-ASCII keyboard layout should be reloaded because of flawed implementation.
  3. 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 overpass 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

Linux serial console is a console implementation via serial port. It may be used in some embedded systems, and on servers, where a direct interaction with operator is not expected. The serial console allows the same mode of access for the system, but usually at a slower speed due to the small bandwidth of RS-232. A serial console is often used during development of software for embedded systems, and is sometimes left accessible via a debug port.

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).

Name Major Minor Description
/dev/tty1

/dev/tty63
c   4 1

63
virtual consoles
(keyboard controlled)
/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
Full image of a virtual text buffer; first 4 bytes contain numbers of rows, columns and cursor position
/dev/ttyS0
c   4 64
Serial ports, suitable for system console
/dev/tty0 c   4 0 “current console”

References

  1. ^ a b c "The Framebuffer Console". kernel.org. 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. {{cite web}}: horizontal tab character in |quote= at position 294 (help)
  2. ^ "Linux Braille Console". kernel.org.
  3. ^ "Linux Serial Console". kernel.org.
  4. ^ "chvt(1) - Linux man page: chvt - change foreground virtual terminal".
  5. ^ "console(4) - Linux man page: console - console terminal and virtual consoles". A Linux system has up to 63 virtual consoles
  6. ^ "console_codes(4) - Linux man page: console_codes - Linux console escape and control sequences".