Linux Programmer’s Manual
console_codes − Linux console escape and control sequences
The Linux console implements a large subset of the VT102 and ECMA-48/ISO 6429/ANSI X3.64 terminal
controls, plus certain private-mode sequences for changing the color palette, character-set mapping, etc. In
the tabular descriptions below, the second column gives ECMA-48 or DEC mnemonics (the latter if pre-
fixed with DEC) for the given function. Sequences without a mnemonic are neither ECMA-48 nor VT102.
After all the normal output processing has been done, and a stream of characters arrives at the console
driver for actual printing, the first thing that happens is a translation from the code used for processing to
the code used for printing.
If the console is in UTF-8 mode, then the incoming bytes are first assembled into 16-bit Unicode codes.
Otherwise each byte is transformed according to the current mapping table (which translates it to a Unicode
value). See the Character Sets section below for discussion.
In the normal case, the Unicode value is converted to a font index, and this is stored in video memory, so
that the corresponding glyph (as found in video ROM) appears on the screen. Note that the use of Unicode
(and the design of the PC hardware) allows us to use 512 different glyphs simultaneously.
If the current Unicode value is a control character, or we are currently processing an escape sequence, the
value will treated specially. Instead of being turned into a font index and rendered as a glyph, it may trigger
cursor movement or other control functions. See the Linux Console Controls section below for discus-
It is generally not good practice to hard-wire terminal controls into programs. Linux supports a ter-
minfo(5) database of terminal capabilities. Rather than emitting console escape sequences by hand, you
will almost always want to use a terminfo-aware screen library or utility such as ncurses(3), tput(1), or
Linux Console Controls