User:Teppic74/Linux console

From ArchWiki
Jump to: navigation, search

From Wikipedia:

The Linux console is a system console supported by the Linux kernel (a system console is the device which receives all kernel messages and warnings and which allows logins in single user mode). 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.

As with all standard distributions, Arch Linux fully implements the Linux console. This article describes the configuration of the console, in terms of hardware, font display, and keyboard input.


The console, unlike most services that interact directly with users, is implemented in the kernel. This contrasts with terminal emulation software, such as Xterm, which is implemented in user space as a normal application. The console has always been part of released Linux kernels, but has undergone changes in its history, most notably the transition to using the framebuffer and support for Unicode.

Despite many improvements in the console, its full backward compatibility with legacy hardware means it is limited compared to a graphical terminal emulator.

Virtual consoles

The console is presented to the user as a series of "virtual consoles". These give the impression that several independent terminals are running concurrently; each virtual console can run its own shell, have its own font settings, and be logged in with different users. The virtual consoles each use a device /dev/ttyX, and you can switch between them by pressing Alt+Fx (where x is equal to the virtual console number, beginning with 1). The device /dev/console is automatically mapped to the active virtual console.

Text mode

Since Linux originally began as a kernel for PC hardware, the console was developed using standard IBM CGA/EGA/VGA graphics, which all PCs supported at the time. The graphics operated in VGA text mode, which provides a simple 80x25 character display with 16 colours. This legacy mode is similar the capabilities of dedicated text terminals, such as the DEC VT100 series. It is still possible to boot in text mode if the system hardware supports it, but almost all modern distributions (including Arch Linux) use the framebuffer console instead.

Framebuffer console

As Linux was ported to other non-PC architectures, a better solution was required, since other architectures do not use VGA-compatible graphics adapters, and may not support text modes at all. The framebuffer console was implemented to provide a standard console across all platforms, and so presents the same VGA-style interface regardless of the underlying graphics hardware. As such, the Linux console is not a terminal emulator, but a terminal in its own right. It uses the terminal type linux, and is largely compatible with VT100.


Character set

Traditionally character sets consisted of 256 codes. This is because text was represented as one character per (8-bit) byte, with each byte having a possible value of 0-255; each character that can be shown uses a different code. All Unix systems support ASCII, which takes up the majority of the codes from 0-127. The remainder are generally configured in what is called a "character set" or a "codepage". The standard VGA adapter uses IBM CP437, which is designed for the English language, together with some very common accented letters, drawing characters, and some symbols. Unix systems have instead traditionally used ISO-8859 sets, such as the very common ISO-8859-1 for "western European Latin" characters.

The Linux console supports bitmap fonts of 256 to 512 symbols (or "glyphs"). The standard is 256, and using more than this causes the number of colours to be halved to 8. With a 256-glyph font, the font is designed with the character set in mind. Thus the 'lat1' console fonts support the ISO-8859-1 set, and so on.


Although console fonts are strictly limited to 256-512 glyphs, the console supports Unicode, and this is the default mode. Therefore fonts can include any Unicode symbols. In practice, most console fonts (being limited to 256 glyphs) support just the characters in the related character set. With 512-glyph fonts, several character sets may be covered, in which case hundreds of symbols can be displayed successfully, with the downside of reduced colours.

Setting the console font

You can view the current console font in tabular format as follows:

$ showconsolefont

The installed fonts are located in /usr/share/kbd/consolefonts/. Generally the font name contains the character set it is designed for and the size of the font. For example, lat9w-16.psfu.gz supports the "Latin 9" ISO character set and has a size of 8x16. To load this particular font, simply run:

$ setfont lat9w-16
Note: Fonts with the psfu extension contain a Unicode mapping, which means that all of the glyphs in the font are automatically mapped correctly. The setfont command allows you to specify explicit mappings, but this is not normally necessary.

If you wish to have support for as many characters as possible, the 512-glyph fonts are recommended, especially if you do not use colours in the console. For example, LatGrkCyr-8x16.psfu.gz contains just about all common Latin accented characters, together with many Greek and Cyrillic characters. For more general work, a standard 256-glyph font appropriate for your language is recommended, since this will not affect the console colours. The default (CP437) font is suitable for many people, but it does not support the Euro symbol.



Scan codes

Modifying keymaps

See also