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.
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
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
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.