Your keyboard and mouse are your interface to Linux, so you should customize them to match your personal tastes and habits.
First of all, make sure that the has the correct keyboard layout, so you get the correct character when you press a key.
But beyond that very fundamental step, you may want to remap some of the special keys like Shift, Control, Alt, Compose, and especially CapsLock. Some systems have those keys laid out a little unusually, so you get unwanted results when touch-typing on the server console that you infrequently use.
The CapsLock can be especially dangerous! My personal preference is to simply turn it into another Control key. But if you want to swap the CapsLock and left Control key, I’ll show you how to do that, too.
As for the mouse, left-handers may find it easier to reverse the order of the buttons so the primary button to click is under the index finger.
Finally, I mentioned the Compose key — we need that to enter accented characters (è, é, ê and so on), and other characters not on your keyboard (£, ð, ø, and so on).
That’s a big list, but they are easy to do. Let’s get started!
This should have been done during the installation, but what if you chose incorrectly then? (UK and US are adjacent in the list…) Or, what if some other administrator (not you, obviously!) made an inappropriate change?
You may wonder how you are supposed to run commands or, worse yet, edit files when you don’t know which character a key is going to produce. You don’t. Connect in over SSH from a nearby machine with a well-configured keyboard and do the work there. Then step over to the physical console of the machine you’re working on and experiment with key presses. Act as if you’re about to try logging in as `~!@#$%^&*()_-+={}[]\|<>?
and make sure the punctuation marks are in their proper places.
You can interactively change the layout with the loadkeys
command.
# loadkeys us
If you don’t know what to use, you can get a list of available choices:
# find /usr/lib/kbd/keymaps | sort
Once you figure out the appropriate layout code, specify that in /etc/sysconfig/keyboard
. Here’s what I find in mine:
KEYBOARD=us KEYTABLE=us XkbModel=pc105 XkbLayout=us XkbOptions=compose:rwin
The first two matter for what we’re discussing so far: getting the kernel to map the correct character codes to the keys. The ones starting Xkb*
are used by the X server. Make sure you also make the equivalent change there!
I find CapsLock an annoyance at best, and often it becomes dangerous. In vi
, h,j,k,l
should be single-position moves left, down, up, and right. But if you have hit the CapLock…
Without Caps Lock | |
h |
One position left |
j |
One position down |
k |
One position up |
l |
One position right |
With Caps Lock | |
H |
Jump to the first non-blank character on the top line within the visible buffer |
J |
“Jerk” the next line so it is appended to the current line |
K |
Do a man -k keyword lookup forthe word currently under the cursor |
L |
Jump to the first non-blank character on the bottom line within the visible buffer |
I don’t want the CapsLock key doing strange and unwanted things. If I really need to UNLEASH THE RAGE OF ALL CAPS, I will hold down a shift key.
I could solve this through system administration as you learn in the Linux server administration course, see how to do that here. But let’s make this a personal change.
The easiest way is through the Gnome or KDE desktop settings menu. If that doesn’t work for you, put this into your ~/.xmodmaprc
file:
! ! Caps_Lock <- Control ! remove Lock = Caps_Lock keysym Caps_Lock = Control_L add Control = Control_L
Then, in a shell startup file, in a section only used during interactive shell sessions, add this:
xmodmap ~/.xmodmaprc > /dev/null
To swap the positions of CapsLock and the left Control key, use this:
! ! Swap Caps_Lock and Control_L ! remove Lock = Caps_Lock remove Control = Control_L keysym Control_L = Caps_Lock keysym Caps_Lock = Control_L add Lock = Caps_Lock add Control = Control_L
To reverse the mouse button order, add this to ~/.xmodmaprc
:
pointer = 3 2 1
That’s all I have room for this week! Come back next week to see how to enter characters you don’t have on your keyboard. There are several ways, so part is knowing how to do them, another is choosing the appropriate one for the situation.
PS – Make sure to check out our 5 new 1-day, online Linux courses here. We have sessions on the Command Line, Shell Scripting with Bash, Text Processing with awk & Linux Booting.