← Back to Guides Homepage

How to Change Keyboard Layout on Ubuntu Server

In this guide, I will show you how to change the default keyboard layout on your Ubuntu Server. This is essential if you need to use specific characters or a different language mapping, such as switching from US English to Swedish.

Step 1: Check Current Configuration

First, log into your server via SSH. It is always good practice to ensure your system is up to date before making changes:

sudo apt update && sudo apt upgrade

You can check the current keyboard configuration by inspecting the default keyboard file. This will show you the current model (e.g., pc105) and layout (e.g., us):

cat /etc/default/keyboard

Step 2: Reconfigure the Keyboard Package

To change the settings, we will use the package reconfiguration tool. This launches a text-based wizard to guide you through the process.

sudo dpkg-reconfigure keyboard-configuration

Wizard Steps:

  1. Keyboard Model: Select the model that matches your hardware. The default (Generic 105-key PC) is usually correct for most standard keyboards.
  2. Country of Origin: Select your desired language/country (e.g., Swedish).
  3. Keyboard Layout: Choose the specific layout variant. Often the default option for the country is sufficient.
  4. AltGr Key: Choose the key to function as AltGr. The default layout is typically fine.
  5. Compose Key: Select a Compose key if needed, or choose "No compose key".

Step 3: Verify and Apply Changes

Once the wizard completes, you can verify the change by checking the configuration file again. You should see the new country code (e.g., XKBLAYOUT="se").

cat /etc/default/keyboard

You do not need to reboot the entire server. Instead, simply restart the keyboard setup service to apply the changes immediately:

sudo service keyboard-setup restart

You can now test your keyboard to confirm that your specific language characters are working correctly.

← Back to Guides Homepage