When running X I use a .xmodmaprc to remap certain keys thusly:

! Make it so that both Caps Lock and Escape do Escape
clear Lock
keysym Caps_Lock = Escape
! Remap the menu key as Compose
keysym Menu = Multi_key

How can I accomplish the same things on the console?


In addition to the partial solution given in my answer, I've learned that the console maps CTRL-. to Compose. So I may be able to get used to that. Setting up the Menu key as Compose is not so easily done, as there are a ton of nul-assigned keycodes and no obvious contender for an alternate name for Menu.

I've also realized that the compose bindings themselves are much more limited than what I'm used to under X, and that most of the special characters I use frequently are not there. Perhaps there is a utility that will translate X-syntax compose bindings into something that loadkeys can read?

  • 1
    Traditionally: with loadkeys. I think nowadays you can get the Linux console to read the X configuration, but I don't know how this works. Commented Feb 19, 2011 at 14:13

4 Answers 4


You'll have to edit your console keymap. On my console, I have mapped Escape to Caps Lock and Caps Lock to Escape. Here's how it works.

  1. First you need to find your keymap. I use the standard US layout. On my system, it is located under /usr/share/keymaps/i386/qwerty/us.map.gz.
  2. Make a copy of the file under a new name, for example us-nocaps.map.gz.
  3. Unpack the file and open it in a text editor: gunzip us-nocaps.map.gz && vim us-nocaps.map
  4. Change the mappings in the file to your liking, for example I had keycode 58 = Caps_Lock which I changed to keycode 58 = Escape.
  5. Gzip the file and load it: gzip us-nocaps.map && loadkeys us-nocaps.

One more thing: You'll probably have to configure your distribution somehow to make sure the new keymaps always gets loaded on boot, otherwise you'll have to load your keymap manually with loadkeys all time. How you do that depends on what distribution you're using.

  • 1
    The gunzip step isn't actually necessary here - in most versions of vim you should just be able to vim us-nocaps.map.gz Commented Jul 23, 2015 at 18:16

For newer Debian distributions you do not need all this anymore.

The keyboard file describes the properties of the keyboard. It is read by setupcon(1) in order to configure the keyboard on the console. In Debian systems the default keyboard layout is described in /etc/default/keyboard and it is shared between X and the console. (man keyboard)

In /etc/default/keyboard set XKBOPTIONS="caps:escape" and then do:

~$ sudo setupcon

Description of all available keyboard models, layouts, variants and options is available in /usr/share/X11/xkb/rules/xorg.lst." (man keyboard)


With some help from Cedric, I've discovered that Ubuntu hasn't installed the keymaps where $ man loadkeys says they are supposed to be (/usr/share/keymaps). This is a brand-new install, so maybe I just need to install a package in order to get keymaps other than the one I selected during installation.

In lieu of pursuing that angle, and in an effort to make the solution a bit more robust and convenient, I'm doing this:

    $ sudo dumpkeys | sed 's/CtrlL_Lock/Escape/' | sudo loadkeys

Although I'm a bit confused as to why Cedric's system uses Caps_Lock for caps lock and mine uses CtrlL_Lock, it is working regardless.

  • That's interesting, I didn't know there where differences across distributions with those keymaps. Personally I use Gentoo, the keymaps are from the sys-apps/kbd-1.15 package.
    – Cedric
    Commented Feb 20, 2011 at 15:11
  • 2
    As of Ubuntu 10.04, the keymaps are in the console-data package. They're not installed by default. You can find out what package installs files in /usr/share/keymaps by running apt-file search /usr/share/keymaps. Commented Feb 20, 2011 at 19:55

echo $"\n(sleep 5 && setxkbmap -option caps:swapescape) &" >> ~/.profile

Worked for me on Linux Mint Cinnamon (not only for terminal, but also on GUI).

The sleep part was necessary for me to delay the execution of setxkbmap. You can try without it and see if it works.

You must log in to answer this question.

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