Software & AppsOperating SystemLinux

How To Create a Custom Keyboard Layout on Ubuntu

Ubuntu 11

Creating a custom keyboard layout on Ubuntu can be a beneficial task for those who frequently use special characters, or for those who prefer a unique key arrangement. In this guide, we will walk you through the process of creating your own keyboard layout.

Quick Answer

Creating a custom keyboard layout on Ubuntu involves navigating to the keyboard layout directory, creating a new layout file, defining the layout in the file using XKB syntax, modifying the evdev.xml file, and applying the changes by restarting the computer or logging out and logging back in.


Before we begin, please ensure that you have administrative access to your Ubuntu system. This is necessary because we will be modifying system files.

Understanding XKB

The X Keyboard Extension, or XKB, is a part of the X Window System that extends the ability to control the keyboard over what is offered by the X Window System core protocol. The main practical benefit to the user is the ability to specify a keyboard layout.

Step 1: Navigate to the Keyboard Layout Directory

The first step is to open the terminal and navigate to the directory where keyboard layouts are stored. You can do this by entering the following command:

cd /usr/share/X11/xkb/symbols/

Step 2: Create a New Keyboard Layout File

Next, we will create a new file for your keyboard layout. For instance, if you want to create a layout called “mylayout”, you would run the following command:

sudo touch mylayout

The touch command is used to create a new empty file.

Step 3: Define Your Keyboard Layout

Now, we need to define the layout of our keyboard. Open the newly created file in a text editor by running:

sudo nano mylayout

Here, nano is a command-line text editor, and sudo is used to run the command with administrative privileges.

In the file, you will define your keyboard layout using the XKB syntax. You can refer to existing layout files in the directory for guidance. Here’s an example of a layout definition:

partial alphanumeric_keys
xkb_symbols "basic" {
 name[Group1]= "My Layout";
 key <AE01> { [ 1, exclam, U00A1, exclamdown ] };
 key <AE02> { [ 2, at, U00B2, U00B3 ] };
 // Define the rest of your keys here

In this example, the layout is named “My Layout” and the keys <AE01> and <AE02> are defined with their respective characters for different levels.

Step 4: Modify the evdev.xml File

To add the new layout to the system, you need to modify the evdev.xml file. Open it in a text editor:

sudo nano /usr/share/X11/xkb/rules/evdev.xml

Scroll down to the <layoutList> section and add the following code after the last </layout> tag:

 <shortDescription>My Layout</shortDescription>
 <description>My Custom Keyboard Layout</description>

Replace “mylayout” with the name you used for your layout and customize the short description, description, and language as needed.

Step 5: Apply the Changes

Finally, you need to restart your computer or log out and log back in for the changes to take effect. Once you’ve logged back in, you can select your custom keyboard layout from the system settings or the keyboard layout indicator.


Creating a custom keyboard layout on Ubuntu might seem a bit daunting at first, but with a little patience and understanding of the XKB syntax, it can be a straightforward process. Remember, this guide is a basic introduction to creating a custom keyboard layout, and there are many more advanced options and modifications you can make to suit your specific needs.

For more information about XKB, you can refer to the official XKB documentation.

Remember, making changes to system files can have significant effects on your system, so always proceed with caution and make sure you understand the changes you are making. Happy customizing!

Can I create multiple custom keyboard layouts on Ubuntu?

Yes, you can create multiple custom keyboard layouts on Ubuntu. Simply repeat the steps outlined in this guide for each layout you want to create.

Can I modify an existing keyboard layout instead of creating a new one?

Yes, you can modify an existing keyboard layout instead of creating a new one. Instead of creating a new file in Step 2, you can open the existing layout file in a text editor and make the necessary modifications.

How do I switch between different keyboard layouts?

Once you have created or modified your custom keyboard layouts, you can switch between them by going to the system settings or using the keyboard layout indicator in the top-right corner of the screen. Select the desired layout from the available options.

Can I share my custom keyboard layout with others?

Yes, you can share your custom keyboard layout with others. You can either provide them with the layout file you created in Step 2 or share the modified evdev.xml file from Step 4. They can then follow the steps outlined in this guide to install the layout on their Ubuntu system.

Will creating a custom keyboard layout affect my existing keyboard shortcuts?

No, creating a custom keyboard layout should not affect your existing keyboard shortcuts. Keyboard shortcuts are typically associated with specific actions or applications and are not tied to the layout itself. However, if you modify an existing layout and change the keys’ functionality, it may affect any shortcuts that were previously assigned to those keys.

Can I remove a custom keyboard layout once it’s been created?

Yes, you can remove a custom keyboard layout. To do this, navigate to the /usr/share/X11/xkb/symbols/ directory and delete the file corresponding to your layout. Additionally, you may need to remove the corresponding entry from the evdev.xml file in the /usr/share/X11/xkb/rules/ directory. After making these changes, you may need to restart your computer or log out and log back in for the changes to take effect.

Can I use my custom keyboard layout on other Linux distributions?

The process described in this guide is specific to Ubuntu, but the concept of creating a custom keyboard layout is applicable to other Linux distributions as well. However, the file paths and specific commands mentioned in this guide may differ. It is recommended to consult the documentation or resources specific to the Linux distribution you are using.

Leave a Comment

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