34

I use a Turkish keyboard which I have converted to English (Ubuntu server 12.04). My problem is that the single quote is not present on the keyboard but is instead represent by a comma in midair. To fix this I use the command

sudo dpkg-reconfigure keyboard-configuration

The problem is each time I shutdown, changes are reverted thus every time I start the system, I have to type that command. I was thinking of making it a cronjob but I`m sure there can be another way to make the changes permanent.

Gryu
  • 8,002
  • 9
  • 37
  • 53
sosytee
  • 2,738

6 Answers6

31

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.

Private
  • 4,074
11

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

Fabby
  • 35,017
7

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
Forivin
  • 378
5

I was having the same problem since last year and i was everytime setting the keyboard layout when starting the system. I tried all methods but none helped except one which i found helped me :)

  • Go > Applications > System tools > Preferences > Startup Application
  • Add new
  • Name: Default Keylayout
  • Command: setxkbmap us
  • Save

Restart the system :)

2

For console-only instances e.g. servers, you should install the console-data package with apt-get install console-data and then set it up with dpkg-reconfigure console-data.

David G
  • 133
1

I tried all of the above on an Ubuntu 16.04 and only the temporary solution setxkbmap xx did it for me so I manually included it in the .bashrc profile: sudo nano ~/.bashrc and then type setxkbmap xxreplacing xx with yor language code