Software & AppsOperating SystemLinux

How To Change Terminal Keyboard Layout in Ubuntu 20.04

Ubuntu 14

In this article, we will provide a detailed guide on how to change the terminal keyboard layout in Ubuntu 20.04. This can be a useful operation if you are using a different keyboard layout than the default one.

Quick Answer

To change the terminal keyboard layout in Ubuntu 20.04, you can use the setxkbmap command in a graphical session or the loadkeys command in a virtual console session. However, it’s important to note that these changes are temporary and will be reset after a system reboot. For permanent changes, you may need to modify system configuration files.

Understanding Keyboard Layouts

Keyboard layouts define the arrangement of keys and their respective outputs. They can vary based on language, region, or user preference. Ubuntu, like other Linux distributions, supports a wide range of keyboard layouts.

Changing Keyboard Layout in a Graphical (X11) Session

In a graphical session, the setxkbmap command is used to change the keyboard layout. The syntax of the command is as follows:

setxkbmap -layout "<chosen-layout>"

Here, <chosen-layout> is the layout you want to switch to. For example, if you want to switch to the French keyboard layout, you would use:

setxkbmap -layout "fr"

This command sets the keyboard layout to French for the current X session. Please note that this change is temporary and will be reset to the default layout after a system reboot.

Changing Keyboard Layout in a Virtual Console (TTY) Session

In a virtual console or text-only TTY session, changing the keyboard layout is a bit more complex and might require superuser permissions. The loadkeys command is used for this purpose. However, it is important to note that not all users may have the permission to execute this command.

If you have the necessary permissions, you can use the loadkeys command in conjunction with the ckbcomp command to change the keyboard layout. Here is the syntax:

loadkeys < <(ckbcomp -layout '<chosen-layout>')

In this command, ckbcomp prepares a keyboard layout file for loadkeys to use. The <chosen-layout> is the keyboard layout you want to switch to.

For example, to switch to the German keyboard layout, you would use:

loadkeys < <(ckbcomp -layout 'de')

This command sets the keyboard layout to German for the current TTY session. However, similar to the graphical session, this change is temporary and will be reset to the default layout after a system reboot.

Checking Available Keyboard Layouts

To check the available keyboard layouts, you can use the man xkeyboard-config command. This command opens the manual page for the xkeyboard-config utility, which provides a list of all supported keyboard layouts.

Conclusion

Changing the terminal keyboard layout in Ubuntu 20.04 can be a straightforward process in a graphical session, but it might require superuser permissions in a TTY session. It is also important to note that these changes are temporary and will be reset after a system reboot. For permanent changes, you may need to modify system configuration files, which is beyond the scope of this article. Always remember to check the available keyboard layouts using the man xkeyboard-config command before making any changes.

How can I check my current keyboard layout in Ubuntu 20.04?

To check your current keyboard layout in Ubuntu 20.04, you can use the setxkbmap -query command in a terminal. This command will display information about the current keyboard layout, including the layout code.

Can I set a permanent keyboard layout in Ubuntu 20.04?

Yes, you can set a permanent keyboard layout in Ubuntu 20.04 by modifying the system configuration files. One way to do this is by editing the /etc/default/keyboard file and changing the value of XKBLAYOUT to your desired layout code. However, modifying system configuration files requires superuser permissions and should be done with caution.

How can I switch back to the default keyboard layout in Ubuntu 20.04?

To switch back to the default keyboard layout in Ubuntu 20.04, you can use the setxkbmap command with the default layout code. The default layout code for Ubuntu 20.04 is usually "us". You can use the following command to switch back to the default layout:

setxkbmap -layout "us"
Can I set different keyboard layouts for different user accounts in Ubuntu 20.04?

Yes, you can set different keyboard layouts for different user accounts in Ubuntu 20.04. Each user can customize their keyboard layout settings individually. The changes made by one user will not affect the keyboard layout of other users.

How can I make the keyboard layout change persistent across reboots in Ubuntu 20.04?

To make the keyboard layout change persistent across reboots in Ubuntu 20.04, you can modify the /etc/default/keyboard file. Open the file with a text editor, locate the XKBLAYOUT line, and change the value to your desired layout code. Save the file and the keyboard layout will be applied automatically on system startup. Remember that modifying system configuration files requires superuser permissions.

Leave a Comment

Your email address will not be published. Required fields are marked *