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.

0

6 Answers 6

30

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.

2
  • 1
    This does not work by ubuntu server 14.04. I replaced the "us" with "hu" (Hungarian), but after reboot I still have English layout instead of Hungarian. sudo dpkg-reconfigure keyboard-configuration worked for me, and it is permanent, I have Hungarian layout after reboot.
    – inf3rno
    Feb 5, 2016 at 13:42
  • how can i get the values to put into these fields that are reconfigured by the 'keyboard-configuration' ? My keyboard turns british after reboots Dec 15, 2017 at 4:21
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

1
  • 1
    This was it! I choose 104 key layout for my keyboard and after choosing the defaults after that, my keyboard is back to normal again. Thank you
    – smac89
    Jul 18, 2018 at 17:39
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
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 :)

1
  • 1
    Probably the easiest solution. Also worked for my Belgium azerty keyboard using 'setxkbmap be', for which I was struggling (because it's a slight variation of the French keyboard and Ubuntu seems a bit lost trying to recognize it)
    – Pascal
    Jun 27, 2019 at 4:53
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.

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

1
  • Only answer that worked for me in debian/bunsenlabs/openbox.
    – nilon
    May 12, 2020 at 19:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .