How do we remap the Caps Lock key to something more useful, say the Esc key? Why the Esc key? See my earlier article.
First, specify the new key mapping in the file ~/.Xmodmap:
$ cat >> ~/.Xmodmap
remove Lock = Caps_Lock
keysym Caps_Lock = Escape
Note that the file ~/.Xmodmap may not pre-exist in your distro. The above command will create the file.
Next, execute those new mappings by:
$ xmodmap ~/.Xmodmap
Test it out by opening a command window in X. Type in some words on the command line. Press the new Esc key(formerly Caps Lock), and then the key b. This should move the cursor back a word.
The above will do the key remapping for your X-Window environment. The key mapping is not changed for your console windows. We will save that topic for another day.