To set the correct keyboard layout on Red Hat 8 Linux console, you must modify the vconsole.conf file located in /etc/vconsole.conf. This configuration ensures that the virtual terminals (TTY) use the specified layout immediately upon boot or session start, resolving input issues in the text-mode interface.
Understanding Console Keyboard Configuration
Red Hat Enterprise Linux 8 utilizes systemd and the XKB framework to manage input devices. While graphical environments often handle keyboard mapping dynamically through desktop settings, the pure text console requires a static configuration file. The primary file governing this behavior is/etc/vconsole.conf. If this file is missing or misconfigured, the system defaults to a US layout, which causes frustration for users with non-US keyboards who see incorrect characters when typing symbols like quotes, brackets, or currency signs.
It is important to note that changes made here affect only the virtual consoles accessible via key combinations like Ctl+Alt+F1 through Ctl+Alt+F6. They do not directly alter the layout for SSH sessions or graphical login screens, which may require separate configuration steps depending on your display manager.
Identifying Your Desired Layout
Before editing any files, you need to know the exact name of the keyboard layout you want to apply. You can list all available layouts by running the following command in the terminal:localectl list-xkb-layouts
This command outputs a long list of layout codes. Common examples include us, gb, de, fr, and es. For more detailed information about variants, such as specific regional variations, you can query the XKB rules:
localectl list-xkb-options
If you are unsure which layout matches your physical keyboard, check the documentation for your country or region. For instance, a French Canadian user might select fr with a variant option if needed, while a standard UK user would use gb. Once you have identified the correct code, proceed to the configuration step.
Modifying vconsole.conf
The most direct method to change the console layout is to edit the/etc/vconsole.conf file using a text editor with root privileges. Open the file using vi or nano:
sudo vi /etc/vconsole.conf
Inside this file, you will find lines defining KEYMAP. By default, it might be commented out or set to us. Change this line to match your desired layout. For example, to set a German layout, the line should read:
KEYMAP=de
You can also specify variants or options if necessary. For example, to add a specific dead key option, you might append it, though usually, the base layout code is sufficient for most standard configurations. Save the file and exit the editor.
After saving the changes, you do not necessarily need to reboot the system. You can apply the new layout immediately by running:
sudo localectl set-keymap de
Replace de with your chosen layout code. This command updates both the configuration file and the current kernel keymap, ensuring consistency across reboots and immediate application.
Verifying the Configuration
To confirm that the change was successful, check the current status using:localectl status
Look for the VConsole Keymap field in the output. It should now reflect the layout you selected. Additionally, switch to a different virtual console (e.g., press Ctl+Alt+F3) to verify that the keyboard behaves correctly in the text environment. If you encounter issues where the layout does not persist after a reboot, ensure that the /etc/vconsole.conf file has the correct permissions and that no other services are overriding it.
For users experiencing broader input issues that extend beyond the console, such as problems in specific software applications, refer to our guide on Troubleshooting xkb Keyboard Layout Issues on Certain Software. This resource covers scenarios where the system-wide setting works but individual programs fail to interpret it correctly.
Frequently Asked Questions
Does changing the console layout affect SSH connections?
No, modifying /etc/vconsole.conf only affects the local virtual terminals. SSH sessions typically inherit the client's keyboard settings or use the server's locale settings for encoding, but the visual key mapping is determined by the SSH client software you are using on your local machine.
How do I revert to the default US layout?
To revert to the default, simply edit /etc/vconsole.conf again and set KEYMAP=us. Then run sudo localectl set-keymap us to apply the change immediately without a reboot.
Why is my keyboard still wrong after editing the config file?
If the change does not take effect, ensure you ran sudo localectl set-keymap after editing the file. Sometimes, the daemon needs to be restarted, or you may need to switch to a different TTY to see the changes reflected in the current session.
Can I set a different layout for each virtual console?
No, /etc/vconsole.conf applies a single global keymap to all virtual consoles. Each TTY shares the same kernel-level input configuration, so you cannot assign distinct layouts to F1, F2, etc., simultaneously.
What if I need special character variants not included in the standard layout?
You can add XKB options to the KEYMAP_OPTIONS variable in /etc/vconsole.conf. Use localectl list-xkb-options to find valid options, such as those for dead keys or international character support, and append them to the configuration.