Linux console (Русский)

From ArchWiki
Jump to: navigation, search

Tango-preferences-desktop-locale.pngЭта страница нуждается в сопроводителеTango-preferences-desktop-locale.png

Статья не гарантирует актуальность информации. Помогите русскоязычному сообществу поддержкой подобных страниц. См. Команда переводчиков ArchWiki
Состояние перевода: На этой странице представлен перевод статьи Linux console. Дата последней синхронизации: 28 сентября 2018. Вы можете помочь синхронизировать перевод, если в английской версии произошли изменения.

Согласно Википедии:

Консоль Linux - системная консоль, реализованная в ядре Linux. Консоль Linux предоставляет возможность для ядра и других процессов отправлять текстовый вывод пользователю и получать текстовый ввод от пользователя. Пользователь обычно вводит текст с помощью клавиатуры и получает вывод на мониторе. Ядро Linux поддерживает виртуальные консоли - логически раздельные консоли, но которые используют одну и ту же физическую клавиатуру и экран.

Эта статься объясняет основы консоли Linux и как настроить отображение шрифтов в ней. Настройка клавиатуры описана в подстранице Консоль Linux/Настройка клавиатуры.

Реализация

Tango-view-fullscreen.pngThis article or section needs expansion.Tango-view-fullscreen.png

Reason: In what ways is the Linux console limited compared to terminal emulators? (Discuss in Talk:Linux console (Русский)#)

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.

Виртуальная консоль

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 be logged in with different users, run its own shell and have its own font settings. 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.

See also chvt(1), openvt(1) and deallocvt(1).

Текстовый режим

Tango-view-fullscreen.pngThis article or section needs expansion.Tango-view-fullscreen.png

Reason: How do you boot in text mode? (Discuss in Talk:Linux console (Русский)#)

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.

Фреймбуфер консоли

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.

Сочетание клавиш

Сочетание клавиш Описание
Ctrl+Alt+Del Перезагрузка компьютера (указано символической ссылкой /usr/lib/systemd/system/ctrl-alt-del.target)
Alt+F1, F2, F3, ... Переключение на n-ную виртуальную консоль
Alt+ ← Переключение на предыдущую виртуальную консоль
Alt+ → Переключение на следующую виртуальную консоль
Scroll Lock Когда клавиша Scroll Lock включена, ввод/вывод заблокирован
Shift+PgUp/PgDown Прокрутка буфера консоли вверх/вниз
Ctrl+c Завершение текущей задачи
Ctrl+d Вставить EOF (символ конца файла)
Ctrl+z Остановить текущую задачу

Для получения дополнительной информации смотрите console_codes(4).

Шрифты

Note: This section is about the Linux console. For alternative console solutions offering more features (full Unicode fonts, modern graphics adapters etc.), see fbterm, KMSCON or similar projects.

By default, the virtual console uses the kernel built-in font with a CP437 character set,[1] but this can be easily changed.

The Linux console uses UTF-8 encoding by default, but because the standard VGA-compatible framebuffer is used, a console font is limited to either a standard 256, or 512 glyphs. If the font has more than 256 glyphs, the number of colours is reduced from 16 to 8. In order to assign correct symbol to be displayed to the given Unicode value, a special translation map, often called unimap, is needed. Nowadays most of the console fonts have the unimap built-in; historically, it had to be loaded separately.

The kbd package provides tools to change virtual console font and font mapping. Available fonts are saved in the /usr/share/kbd/consolefonts/ directory, those ending with .psfu or .psfu.gz have a Unicode translation map built-in.

Keymaps, the connection between the key pressed and the character used by the computer, are found in the subdirectories of /usr/share/kbd/keymaps/, see /Keyboard configuration for details.

Note: Replacing the font can cause issues with programs that expect a standard VGA-style font, such as those using line drawing graphics.
Tip: For European based languages written in Latin/Greek letters you can use eurlatgr font, it includes a broad range of Latin/Greek letter variations as well as special characters [2].

Предосмотр и временные изменения

Совет: Доступна организованная библиотека изображений для предосмотра: Скриншоты шрифтов консоли Linux.
$ showconsolefont

показывает таблицу глифов или букв шрифта.

setfont временно меняет шрифт, если передать имя шрифта (из /usr/share/kbd/consolefonts/), например

$ setfont lat2-16 -m 8859-2

Таким образом, чтобы иметь маленький шрифт 8x8, с установленным шрифтом, как показано ниже, используйте, например:

$ setfont -h8 /usr/share/kbd/consolefonts/drdos8x8.psfu.gz

Имена шрифтов чувствительны к регистру. setfont без параметра устанавливает шрифт по умолчанию в консоли.

Совет: Все команды, изменяющие шрифт, могут быть напечатаны "вслепую".
Примечание: setfont работает только на используемой консоли. Любые другие консоли, активные или неактивные, остаются незатронутыми.

Постоянные настройки

The FONT variable in /etc/vconsole.conf is used to set the font at boot, persistently for all consoles. See vconsole.conf(5) for details.

For displaying characters such as Č, ž, đ, š or Ł, ę, ą, ś using the font lat2-16.psfu.gz:

/etc/vconsole.conf
...
FONT=lat2-16
FONT_MAP=8859-2

It means that second part of ISO/IEC 8859 characters are used with size 16. You can change font size using other values (e.g. lat2-08). For the regions determined by 8859 specification, look at the Wikipedia:ISO/IEC 8859#The parts of ISO/IEC 8859.

To use the specified font in early userspace, use the consolefont hook in /etc/mkinitcpio.conf. See Mkinitcpio#HOOKS for more information.

If the fonts seems to not change on boot, or change only temporarily, it is most likely that they got reset when graphics driver was initialized and console was switched to framebuffer. To avoid this, load your graphics driver earlier. See for example Kernel mode setting#Early KMS start, [3] or other ways to setup your framebuffer before /etc/vconsole.conf is applied.

Смотрите также