Skip navigation.

Blog

Skip the blog side panel.

Customize your Linux terminal

Hello!

How many like the terminal/console in Linux?

I myself like it, even if I do not use it too much. I use much of the X-based "bling bling": Gnome, Opera, Gaim, Xchat, Quanta, XMMS, etc. However, I particularly enjoy the power the console gives you: the one who says you're somehow limited in the terminal is very wrong. That's because you do almost everything you want: you can play music, you can play browse the web, use any Internet protocol (ftp, bittorent, pop3/imap/smtp mail, etc), you can do programming (of course), etc.

Simply forget about the MS-DOS console you know. That's limited (flame bait). Linux console, even if it looks the same, it's not the same. :)

One thing missing in the GUI approach (KDE, Gnome, Windows, Mac OS X, etc) is consistency. The terminal is always consistent, it's the same on Linux, on Windows and Macs. The commands differ between operating systems, but the basics are the same.

I did four things to customize my terminals on Ubuntu Linux:

1. Console font. I picked a font which includes the most-used non-english characters in the documents I usually view (romanian and french).

To do this after you booted use:

consolechars -f /usr/share/consolefonts/font-file-name

This is handy for testing because the changes will be lost after you restart, plus the changes are applied only to the current terminal.

You shall pick the font-file-name you want. Just take a look at the console fonts you have installed. The ones I have are named based on the character set they can display: iso01, iso02, latin1, koi, etc. I use iso-8859-2 (for Central European).

To make the change permanent just edit /etc/console-tools/config. Change SCREEN_FONT value to the font file name you found to like.

2. Keyboard layout. I changed the keyboard layout to a custom keyboard layout I made, based upon the romanian programmers keyboard layout provided by default in Ubuntu, plus the American international keyboard layout with dead keys. Last, but not least, I also looked into the French keyboard layouts :). My purpose was to have a normal english keyboard layout, but greatly enhanced for Level 3 (activated with the Right Alt key).

To make your own custom keyboard just go to /etc/X11/xkb/symbols and pick the keyboard language you want to start from. Edit it, look into other files to learn what needs to be changed, have fun. :)

Things to know about those files: they contain the symbols associated to each key on the layout. Therefore, they are not exactly keyboard layouts. The files are named based on the country code, and they contain all the keyboard variants belonging to the country. You should be able to add your own, but you need to learn how to do that (you need to edit other files aswell). My file does not add a new variant for two simple reasons: lack of knowledge (caused by lack of spare time to learn how), lack of motivation (caused by the fact I don't want to backup another file). I just modified the basic variant.

XKB is very advanced and complex: you can change the geometry, the rules, the symbols, everything. You can make a single key do wonderful things. Yet, don't ask me how LOL (I am still learning myself). All I know is enough to make my own nice keyboard layout :).

To learn more:

It is important to note all changes also apply to the X server. You can use the keyboard layout in Gnome, KDE and what else you wish.

To change the keyboard layout in the terminal just run kbd-config or

sudo dpkg-reconfigure console-data

In Gnome you must know how to do it, same goes for KDE.

Download my keyboard configuration: xkbd-ro.

If you are a romanian, you'll most likely want this layout :). Save the file as /etc/X11/xkb/symbols/ro (overwrite!).

For maximum fun I edited my xorg.conf to use the custom keyboard layout.

Section "InputDevice" 
Identifier "Generic Keyboard"
Driver "kbd"
Option "CoreKeyboard"
Option "XkbRules" "xorg"
Option "XkbModel" "pc104"
Option "XkbLayout" "ro"
Option "XkbVariant" "basic"
EndSection

For an unknown reason, the keyboard layout does not work exactly in the same way as in X. In the console, the keyboard map is a bit "screwed" and dead keys are out of the discussion, since they are not supported by the font. I'll probably have to make a new variant specialized for the console. Based on what I learned, the difference might be caused by the fact I do not have the same XkbdRules as xorg. I'll see. :)

Suggestion by csant: To edit the keyboard layout, you can also use a GUI-based tool:

sudo apt-get install xkeycaps

3. Sticky keys. I use sticky keys in X, so I wanted to use them in the terminal aswell. The above two guides also provide tips in regards to how to enable sticky keys. Based on other tutorials, there are several ways one can achieve this goal. I picked the "loadkeys method".

The file is:

keymaps 0-6,8-9,12 
keycode 29 = SCtrl
keycode 42 = SShift
keycode 56 = SAlt
keycode 54 = SShift
keycode 97 = SCtrl

Keymaps differ from a configuration to another. So, you need to learn which ones are on your system:

dumpkeys | head -1

Save the above file, after you update it and execute:

sudo loadkeys your-file

Warning: Providing a wrong keymap can render your keyboard unusable (I actually needed to do a forced reset :) ).

Warning 2: Your system might use different keycodes for the same keys. If this is the case, use showkey. Generally, if you have a PC which is "mainstream" (like mine), this should be safe.

If you take a close look at the above, you'll notice the missing second SAlt. That's because the second one (Right Alt = keycode 100) does provide access to level 3, used for inputting special chars. Making it sticky, loses the "special" attribute. I don't know currently how to make the it a sticky without losing the capability of switching to level 3.

The behavior is: you press Shift then a = A. Pressing again a = a. This means that pressing shift will not lock it. For locking-type of sticky keys, read the above two guides.

To make the change permanent, just add the call to loadkeys into your /etc/rc.local.

4. Higher resolution. To do this edit /boot/grub/menu.lst by adding vga=792 to the kernel you use. Something like this:

title           Ubuntu, kernel 2.6.15-25-386 
root (hd0,0)
kernel /vmlinuz-2.6.15-25-386 root=/dev/hda3 ro quiet splash vga=792
initrd /initrd.img-2.6.15-25-386
savedefault
boot

Tips and tricks:

1. VNC for the console. If you like VNC, you can also share your console :). Install the linuxvnc package (use apt-get).

Yet, it's recommended that you use the screen package, which is better. VNC is generally meant for graphical stuff. :)

2. To capture the screen of your terminal, as a text file, use:

sudo setterm -dump

What I want to do next is enable beep for sticky keys, same as in X. Also, I'd add the "locking-type" of sticky keys, exactly as in X: press Shift twice to lock it.