How to change the keyboard layout of your Linux console window
What is it
After creating a virtual machine you may find that in the system console your keypresses generate the wrong characters, typical cases are "z" and "-".
Prerequisites
Login as root to your PS4 system.
Note that the wrong keyboard layout affects just the system console while logins through SSH should work fine. Therefore it is easier to execute below commands in a SSH session.
Also check the serial console terminal offered by your cloud provider or VM environment. Often there is a control to change the keyboard layout, e.g. marked by a keyboard icon. If you temporarily switch to English or US layout it is much easier to enter below commands.
How to achieve it
Install necessary packages: apt install keyboard-configuration console-setup. This brings up a configuration dialog where you choose the desired keyboard layout (as the first screen just shows English layouts first select Other). The change takes effect immediately. (See below for a key mapping table if you use a German keyboard layout and enter the command on the system console which has US keyboard layout.)
If these packages be already installed then
- Execute dpgk-reconfigure keyboard-configuration to manually start the keyboard layout selection dialog.
- For additional question on the Alt Gr and Compose keys leave the default.
- To make the changes effective either execute service keyboard-setup restart or reboot.
Good to know
You can repeat the keyboard configuration dialog at any time by executing dpgk-reconfigure keyboard-configuration, then again issue service keyboard-setup restart.
It is also possible to change the console font by running dpkg-reconfigure console-setup. The change will take effect immediately.
Should you have a German keyboard (QWERTZ) and just need one or two commands you may get along by simply pressing the right wrong keys on your keyboard:
for y press z
for z press y
for - press ß
for _ press Shift+ß
for ( press Shift+9
for ) press Shift+0
for < press Shift+, (comma)
for > press Shift+: (colon)
for / press - (minus)
for " press Shift+ä
for = press ` (backquote)
for @ press Shift+2
for # press Shift+3
for : press Shift+ö
for | press Shift+#
for \ press #
for ? press Shift+-