Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Exactly what the title asks. How do I clear xmodmap settings?

I have an IBM model M, and somehow xkeycaps got it into its head that my "End" key was not any key at all. xev reports keypresses when I use it, so I know the event is being generated by the keyboard. Also, xkeycaps thinks that my arrow keys are all wonky, and apparently the scrollbar is broken so it only scrolls down - so I can't scroll up to find an IBM keyboard that just maybe is close to my map so I can fix my keys.

So I'm trying to reset my keyboard to the default settings, but the xmodmap manpage is woefully devoid of "reset all" or "clear all" or anything of that nature (that I was able to find).

Help would be greatly appreciated!

share|improve this question
up vote 40 down vote accepted

xmodmap has no notion of state, so it has no way to reset state directly. You can simulate it by using xmodmap -pke >.xmodmap.orig before making any changes (although it doesn't save the modifier map, which you would have to save and restore manually) — but it's a bit too late for that.

Modern systems don't generally use xmodmap to configure the keyboard, though. setxkbmap is the modern way to do it; and that does reset bindings when run. So you may be able to use setxkbmap -layout us to reset things to normal. More complete would be to check for the default configuration in /etc/X11/xorg.conf. For example, on my system

jinx:718 Z$ sed -n '/Identifier.*Keyboard/,/EndSection/p' /etc/X11/xorg.conf
        Identifier      "Generic Keyboard"
        Driver  "kbd"
        Option  "XkbModel"      "pc105"
        Option  "XkbLayout"     "us"
        Option  "XkbOptions"    "grp:alt_shift_toggle"

The corresponding command is

setxkbmap -model pc105 -layout us -option grp:alt_shift_toggle

If there were an XkbVariant entry in the output, you would pass its value with -variant. One thing to watch out for is that options are handled specially: you can only set one option per -option parameter, and you need to use -option '' to reset parameters first. So to fully reset when there is something like XkbOptions "grp:alt_shift_toggle,grp:ctrls_toggle" you would need

setxkbmap -model pc105 -layout us -option '' -option grp:alt_shift_toggle -option grp:ctrls_toggle
share|improve this answer
setxkbmap -layout us has reset my keys, thank you! – Dan Nov 8 '11 at 13:20
Another very helpful option I discovered is setxkbmap -query to print out the current settings in xkb's format, which helped me to configure my Apple keyboard as desired from the terminal. – metakermit Jul 21 '13 at 11:39

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.