2010-01-17

Changing the Linux console keyboard layout

The problem: you switch to a virtual console using Alt-Gr-1 in order to
quickly debug something. But the key mapping is all wrong because the person
who installed the computer was a Armenian, Swiss German or what not.
You know the solution: loadkeys

But what mapping file? More often than not, I find no keyboard layout files.
This is annoying, because I really just want to fix a few things in the console
and then switch back to X11 and forget about it.

Try:
             loadkeys -d

If this does not set the correct layout directly, it gives you at least
an idea where to look for keyboard layouts.

Permanently change the default keyboard mapping on the linux console.


For example to Swiss German (sg):

  •   login as root
  •   cd /usr/share/keymaps/i386/qwerty  (your mileage may vary)
  •   mv defkeymap.kmap.gz not_my_defkeymap.kmap.gz
  •   cd ../qwertz
  •   ln -s sg-latin1.kmap.gz defkeymap.kmap.gz
  •   loadkeys -d

The point is to create a keyboard definition called defkeymap.kmap.gz
which will be loaded by default.

display the RUNPATH/RPATH of a Unix binary

First a short explanation what RUNPATH / RPATH is and why we want to use it. You know about shared libraries and their advantages over static linking. You also encountered the "shared object xxx not found" problem. There dynamic linker looks in four places for shared objects, in this order:

  1. the environment variable LD_LIBRARY_PATH
  2. a global file /etc/ld.so.conf or its cache /etc/ld.so.cache
  3. the RPATH and RUNPATH information in the executables header
  4. some hardwired default paths like /lib and /usr/lib
Working with binaries, it is advisable to avoid the first two methods whenever possible. They should be left to sysadmins and as a last resort.

RPATH and RUNPATH information is created at link time.

This is how to extract and display RPATH and RUNPATH from a given binary files:

Solaris:
/usr/ccs/bin/dump -Lv <binary> | egrep 'RPATH|RUNPATH'

Linux:
/usr/bin/objdump -p <binary> | egrep 'RPATH|RUNPATH'