Showing posts with label change console keyboard. Show all posts
Showing posts with label change console keyboard. Show all posts

Tuesday, August 11, 2015

Setting the keyboard and language RHEL and CentOS 7 command line

Setting the console keyboard RHEL and CentOS 7

When transferring VMs and systems built in one locale to another the keyboards become a problem.  In the earlier versions of Linux we simply changed a symlink or edited the /etc/sysconfig/keyboard file, but as of version 7 we now have to use localectl or edit the correct files to make the change permanent.

Having read various pages scattered across the Internet a lot of them talk about using the localectl command to change your keyboard and locale settings for a console installation.  However, the localectl command did not update the console keyboard and things such as the | key didn't work when changing from UK to US locale.  Even after a reboot the keyboard would still be wrong.

So how do you get the keyboard changed for the console in RHEL and CentOS 7 permanently?

Persistant Changing The Keyboard and Locale

Here we will assume that the system is currently set to en_GB.UTF-8 and uk keyboard.

1. Edit the /etc/locale.conf file and make sure the following is in it;
LANG="en_US.utf8"

2. Edit the /boot/grub2/grub.cfg file and change
vconsole.keymap=uk    change to    vconsole.keymap=us
Do that for all occurrences, a quick method is;
sed -i 's/vconsole.keymap=uk/vconsole.keymap=us/g' /boot/grub2/grub.cfg

3. Edit /etc/sysconfig/grub and change
vconsole.keymap=uk    change to     vconsole.keymap=us
Like step 2 you can use sed to perform the change as follows;
sed -i 's/vconsole.keymap=uk/vconsole.keymap=us/g' /etc/sysconfig/grub

By doing these steps and then rebooting your system your keyboard and locale would set itself to the new locals for the console.