I made a cool, little script that will edit my /usr/share/X11/xkb/symbols/pc file automatically. It is useful when I want to switch between a Mac or Windows keyboard.

The one problem I've encountered is that I have to log out and then log back in after editing the file in order for the edited configuration to take effect.

I've tried deleting my xkb cache (/var/lib/xkb/*.xkm), but that did work.

Any help would be greatly appreciated. Cheers.

  • 1
    editing the .../symbols/pc file regularly isn't recommended. XKB probably already knows the differences; you just need to know what to tell it to load. if these are different physical keyboards you're switching between, specifying a model will probably do what you want: setxkbmap -model apple -layout us vs -model pc105.
    – quixotic
    Commented Oct 25, 2017 at 20:40

3 Answers 3


Solution. Run this command. Of course, you could change "us" to your desired keyboard layout.

setxkbmap -layout us

  • 1
    Does what you say. The key ingredient for me was an additional -variant foo.
    – primfaktor
    Commented Apr 25, 2019 at 18:55
  • 1
    This actually reload "us" keyboard, but unfortunately disables other keyboard layouts (in case of multi-keyboard use).
    – Name
    Commented Sep 5, 2020 at 17:38
  • @Name you can set variants and other things as you like, you can also specify 1+ layouts to switch between. You can find more info in man setxkbmap.
    – WesternGun
    Commented Apr 23, 2021 at 10:58
  • 1
    Thanks. This reloads my changes in /usr/share/X11/xkb/keycodes/evdev. Good.
    – WesternGun
    Commented Apr 23, 2021 at 11:01
  • Quick note, if you want to select a nondefault variant for a language you can write setxkbmap 'fr(bepo)' where fr is your language and bepo the variant name in the symbol file (not sure if variant is the correct terminology anyway).
    – oowekyala
    Commented Mar 8 at 21:14

It's answered in Unix Stack Exchange:


Basically, you do this:

sudo udevadm trigger --subsystem-match=input --action=change

It is also mentioned that the following might be sufficient, please comment on what system setup it alone helped:

# For Ubuntu < 16.04
service keyboard-setup restart
# For Ubuntu >= 16.04
systemctl restart keyboard-setup

You might come across other answers suggesting you delete /var/lib/xkb/*.xkm. That would be an outdated suggestion. At least in Ubuntu, this directory wasn't used for this purpose for quite a few years.

  • 2
    That doesn’t actually “reload” the keyboard layout, at least not the current one. When I tried on 18.04, it didn’t pick up any of the changes made in /usr/share/X11/xkb/symbols; only sudo udevadm trigger --subsystem-match=input --action=change (also mentioned in the answer and a comment to it) did the trick.
    – user149408
    Commented Jul 17, 2021 at 22:13

Run follwing command to reload XKB:

sudo setxkbmap

don't set -layout option. just execute above command.

You must log in to answer this question.

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