How to permanently configure keyboard

using sudo dpkg-reconfigure keyboard-configuration will change your keyboardlayout just for this session.

go for sudo nano /etc/default/keyboard there you can change your keyboard settings.

Find the line :

XKBLAYOUT="xx"

You can change layout and kboptions as well as your model and the kbvariant.

Just put in tr for Turkish

Keyboard File

on older ubuntu versions you could go for dpkg-reconfigure console-setup and make permanently changes here. but for server 12.04 I guess it should be in the keyboard file.


The keyboard settings are stored in /etc/default/keyboard file. It's provided by the keyboard-configuration package, and other packages use this information in order to configure the keyboard on the console or in X Window System.

You can change your keyboard settings using:

dpkg-reconfigure keyboard-configuration
service keyboard-setup restart

Source


To change it permanently via the terminal run this:

For US:

L='us' && sudo sed -i 's/XKBLAYOUT=\"\w*"/XKBLAYOUT=\"'$L'\"/g' /etc/default/keyboard

For French:

L='fr' && sudo sed -i 's/XKBLAYOUT=\"\w*"/XKBLAYOUT=\"'$L'\"/g' /etc/default/keyboard

For German:

L='de' && sudo sed -i 's/XKBLAYOUT=\"\w*"/XKBLAYOUT=\"'$L'\"/g' /etc/default/keyboard

and so on...

Tested on Ubuntu 16.04 64 bit.


To change it temporarily you can use setxkbmap mylayout...

# US
setxkbmap us
# French
setxkbmap fr
# German
setxkbmap de

In terminal mode, you need to use loadkeys instead of setxkbmap

# US
loadkeys us
# French
loadkeys fr
# German
loadkeys de