Fix a Garbled Virtual Console with unicode_stop
unicode_stop puts a stuck Linux virtual console back into ASCII keyboard mode when UTF-8 mode has left it garbled. This guide uses the installed kbd package, version 2.6.4-2ubuntu2, and shows how to tell a real reset from a command that politely skipped your terminal.
The route
Jump straight to the step you need, or tick off Done means at the end.
- Time: about ten minutes.
- You need: a shell on the affected machine and access to the virtual console you want to repair.
Warning
The command changes terminal state. Do not run it blindly in a terminal emulator or against a console another person is using.
1. Confirm the command and the kind of terminal
Check the installed command first. These checks are ordinary and do not need elevated privileges:
$ command -v unicode_stop
/usr/bin/unicode_stop
$ dpkg-query -W -f='${Package} ${Version}\n' kbd
kbd 2.6.4-2ubuntu2
$ tty
/dev/tty2
That last line is the one that matters. unicode_stop is intended for a Linux virtual console such as /dev/tty2, /dev/tty7 or /dev/console. It is not a general-purpose setting for an SSH session, a graphical terminal emulator or a pseudo-terminal.
Checkpoint
If tty prints not a tty, or a path such as /dev/pts/3, stop here. You are not attached to the target virtual console. Log in on that console instead, or use the console's own recovery path.
2. Warn anyone using the console
Warning
This changes the active virtual console. It switches the keyboard to ASCII, tells the terminal that UTF-8 input is no longer expected, and sends a terminal reset sequence when standard input is a terminal. Screen output and key interpretation can change immediately, so if the console is shared, announce the change first.
Do not use sudo as a way to guess which console is broken. Privilege may be required to change the device, but it cannot identify the correct target for you.
3. Run unicode_stop on the affected virtual console
With the correct virtual console in the foreground, run the command with no options:
$ sudo unicode_stop
$ printf 'exit status: %s\n' "$?"
exit status: 0
The man page gives unicode_stop no command-line options at all. Under the hood, the installed shell script calls kbd_mode -a to select ASCII (also called XLATE) keyboard mode, then clears the terminal's UTF-8 input setting with stty -iutf8. It also sends the terminal's ASCII mode escape sequence when the input is a terminal.
Use elevated privileges only if the command cannot access the console device as your current user; on a local root shell, omit sudo. A successful exit status means the reset steps completed for the selected console. It does not mean every virtual console on the machine was changed.
4. Verify the keyboard mode
Ask kbd_mode to report the mode of the console attached to standard input after the reset:
$ kbd_mode
XLATE
The exact word depends on the console state and the installed kbd_mode build. What you want is the ASCII or XLATE mode described by your local kbd_mode(1) manual, not a raw or medium-raw mode. If the report is unexpected, make sure you ran the command on the affected virtual console and that unicode_stop returned success.
For an explicit console device, kbd_mode supports -C CONSOLE. That changes which console it operates on, but it does not move your shell there, so prefer running the recovery command from the affected console itself.
5. Check the terminal setting without changing it
Once the keyboard mode is correct, inspect the input flags:
$ stty -a
... -iutf8 ...
The exact stty output varies by terminal and system. What matters is that -iutf8 is present, meaning the terminal is no longer asking the line discipline to interpret input as UTF-8. This is a read-only check: do not copy an entire stty line from another machine, since terminal flags are device-specific.
If the display is still garbled, the culprit may be the console font, keymap or application output rather than Unicode mode. unicode_stop does not repair any of those three. The related unicode_start command can restore Unicode mode later, but only once the console and the applications writing to it are ready for UTF-8 again.
6. Recognise a skipped terminal
On a non-console terminal, the installed command reports that it skipped the terminal and exits successfully:
$ unicode_stop
unicode_stop skipped on /dev/pts/3
$ printf 'exit status: %s\n' "$?"
exit status: 0
This is not a failed recovery, it is a deliberate guard: the script only acts when tty identifies /dev/console, /dev/vc* or /dev/tty followed by digits. A zero status here means no reset was needed or attempted on that pseudo-terminal, which is the most common distraction when testing over SSH.
There is no persistent configuration to undo for the normal case. The command only changes the current console's runtime state. To return that console to Unicode mode later, use unicode_start and keep the console font and application encoding consistent. If the reset disrupted a local session, switch to another virtual terminal with the host's normal console key combination and investigate from there.
Done means
- Identified the console.
ttyconfirmed the affected Linux virtual console. - Ran the reset.
unicode_stopreturned success while running on that console. - Verified the mode.
kbd_modeno longer reports UTF-8 mode. - Checked the terminal flag.
stty -ashows the input setting with-iutf8. - Know what actually happened. You can tell whether the command changed the target console or merely skipped a pseudo-terminal.
- Ruled out other causes. You have not confused a font or keymap problem with a console encoding problem.