Main page òÕÓÓËÉÊ ×ÁÒÉÁÎÔ Ðóññêèé âàðèàíò

Last updated: 2005-04-28


Advice on configuring GNU/Linux distribution / installing GNU software

Contents

  1. Foreword
  2. Russian Language Support
  3. Mouse
  4. Sound
  5. Network card

Foreword

This document describes steps you can take to fine-tune your GNU/Linux system. It describes our experience with Debian 3.0 and (to a lesser extent) Red Hat 8.0 distros, but most tricks will apply to other distros as well.


Russian Language Support

General

  1. Make sure that required locale files are built. On Debian, it is as easy as running dpkg-reconfigure locales and selecting locales you want to build. On other systems, you have to use localedef(1) to compile locale files from source definition files and symbolic character names file (their location is displayed by localedef --help). On my Debian GNU/Linux, the following command builds Russian locale for KOI8-R encoding:

    localedef -i ru_RU -f koi8-r ru_RU.koi8r
    
  2. Set LC_* environment variables to your preferred locale. You don't have to set them all, but you should at least set LC_CTYPE (defines interpretation of characters for your locale) and LC_COLLATE (determines collation/sorting order for your locale). See man 1 locale for variables available and their description. If you use bash, add the following to your ~/.bash_profile:

    LC_CTYPE=ru_RU.koi8r
    LC_COLLATE=ru_RU.koi8r
    export LC_CTYPE LC_COLLATE
    

    (In place of ru_RU.koi8r, substitute your locale, which have to be built as described above. For the changes to take effect you have to logout/login.)

    Note that you are better off using KOI8-R encoding. Don't mess with CP1251 (MS Windows) -- some programs may not support it, while KOI8-R is guaranteed for programs with Russian support. If you have to work with texts in CP1251, you have options other than enabling CP1251 throughout your system.

    First, recode is a great tool for converting between a hoard of encodings. When reading text files in non-native encoding, it is best used with a pipe:

    recode cp1251..koi8r < file.txt | less
    

    You can even write a small wrapper script around recode / less pipeline, if you have to often read files in some certain encoding.

    Next, for editing files in CP1251 and CP866 (and many other encodings) you can use Emacs. See Russian Language Support / Emacs.

Console

  1. For fast and easy Cyrillic setup, use console-cyrillic package (available in Debian). Edit /etc/console-cyrillic to your taste.
  2. If you don't have console-cyrillic, you'd have to arrange for consolechars(8) and loadkeys(1) to load respectively Cyrillic console screen font / screen-font map; and Cyrillic keyboard translation table (residing in /usr/share/consolefonts/, /usr/share/consoletrans/ and /usr/share/keymaps/; or in /lib/kbd/consolefonts/, /lib/kbd/consoletrans/ and /lib/kbd/keymaps/). How you do this depends on your distribution. You can run them from system startup scripts, or from your account's startup scripts. For example, in Red Hat 8.0 you have to edit file /etc/sysconfig/i18n to have something like

    SYSFONT="koi8u_8x16"
    SYSFONTACM="koi8-r"
    

    and edit /etc/sysconfig/keyboard to have something like

    KEYBOARDTYPE="pc"
    KEYTABLE="ru1"
    

    (You may have to use different names for font / keymap files.)

    On your next reboot the script /etc/init.d/keytable will read and enable these settings. Which key is used to switch between Cyrillic / Latin layouts depends on the keymap you loaded. It is usually documented at the beginning of the keymap file. You can also create a custom keymap if you don't like any of the preinstalled keymaps.

  3. Many programs use readline(3) library for their console input, including bash(1), so you need also to set up readline to properly process characters with the eighth bit set. Add to your ~/.inputrc (or /etc/inputrc for a system-wide setup) the following lines:

    set input-meta on
    set convert-meta off
    set output-meta on
    

    (Read man 3 readline for their meanings.)

    While we are at it, if that terminal bell is driving you nuts, you can turn it off by setting

    set bell-style visible
    

    Note that this will work only for programs which use readline to read their input from the terminal.

Filesystem drivers

For creating and/or reading files with Cyrillic names on FAT and ISO9660 (filesystem for CDs) partitions you need to setup console (see Russian Language Support / Console) and filesystem drivers. To mount vfat or iso9660 partitions with Cyrillic filenames, give the driver the option

iocharset=XXXX

where XXXX stands for encoding name. For example, I use the following entries in /etc/fstab file to read and/or write files with Cyrillic names on floppies and CD's:

/dev/fd0   /mnt/floppy  vfat    user,noauto,iocharset=koi8-r    0   0
/dev/cdrom /mnt/cdrom   iso9660 ro,user,noauto,iocharset=koi8-r 0   0

Note that to be able to use this option, you have to include Native Language Support (in `File systems' section) and select appropriate encoding when you are building your kernel. As far as I know, there is also (limited) support for NTFS, but I never tried it.

Emacs

Emacs has its own mechanism for supporting international character sets. Whether you use Emacs or XEmacs, enabling Cyrillic support for your console / X Window is not sufficient if you want to have Cyrillic in Emacs.

Emacs internally uses a single multibyte character encoding, so that it can intermix characters from various encodings in a single buffer or string. When reading and writing files, Emacs translates between the multibyte character encoding and various other coding systems.

For interactive input, Emacs defines `input methods'. At the terminal, you may be typing Latin characters without using facilities that your console / X Window provides for entering Cyrillic, but input method currently in effect defines how Emacs translates these Latin characters into the multibyte character encoding Emacs uses internally.

For Emacs to correctly display text on your terminal, you also have to tell Emacs what character encoding your terminal uses. Emacs translates its internal multibyte encoding into this encoding when characters are output to the terminal (be it console or X Window terminal emulator).

One consequence of this scheme is that to use Cyrillic in Emacs, you don't even have to setup your terminal's keyboard for Cyrillic, you only need to have Cyrillic font loaded.

If you are using XEmacs, you can direct XEmacs to use the font you want either by adding the following line to your ~/.Xresources:

emacs*font: -misc-fixed-medium-r-normal--15-140-75-75-c-90-koi8-r

or by adding the following line to your ~/.emacs:

(cond (window-system (set-frame-font "-misc-fixed-medium-r-normal--15-140-75-75-c-90-koi8-r")))

(The latter setting overrides the former. Substitute name of your font -- remember it must support encoding that you select for terminal output, see below. If you choose the first method, you will have to restart X server for the setting to take effect.)

Emacs provides the following commands and variables for all these customizations:

See Emacs manual for more (if it is installed on your system, type info emacs).

All these commands / variables can be run / set in your Emacs initialization file, so that they are applied every time you start up Emacs. Add to your ~/.emacs the following lines:

(set-language-environment 'Cyrillic-KOI8)
(set-terminal-coding-system 'koi8)
(set-keyboard-coding-system nil)
(setq default-buffer-file-coding-system 'koi8)
(set-selection-coding-system 'koi8)
(codepage-setup 1251)

(Adjust the coding systems. For the setting to take effect, restart Emacs.)

Some useful commands related to the coding systems:

X Window

This description applies to XFree86 4.3.0.1. In /etc/X11/XF86Config-4(5), section "InputDevice" for the default keyboard (or for the one you use, if you customized your XF86Config-4), remove (better comment out)

Option "XkbDisable"

This will enable X keyboard extension which provides support for non-US keyboards. Then add

Option  "XkbRules"  "xfree86"
Option  "XkbModel" "pc104"
Option  "XkbLayout" "us,ru"
Option  "XkbOptions" "grp:menu_toggle,grp:rwin_toggle,grp:switch"

This will provide two layouts (US and Russian), and make Menu and right Windows buttons on your Windows keyboard act as a toggle button for switching between the layouts, and right Alt as a (temporary) switch between layouts. If you are lucky enough not to have a Windows keyboard, you can set "grp:toggle" (right Alt) as a toggler for keyboard layouts. Check /etc/X11/xkb/rules/xfree86 for other possible combinations. For more information, read /etc/X11/xkb/README.config.

Also, don't forget to install Cyrillic fonts, if they are not yet installed.

gnome-terminal

I describe version 1.4.0.6. In Preferences dialog set

Open IM (input method)

and unset

Swap Delete/Backspace
Delete generates DEL/^H
Enable multibyte support
Meta sets the eighth bit

Also, choose a Cyrillic font in appropriate encoding.

Xpdf

For Russian language support, I downloaded xpdf-cyrillic.tar.gz and ran the commands (again, paths may vary)

tar xzf xpdf-cyrillic.tar.gz
cd xpdf-cyrillic
install -d /usr/share/xpdf/cyrillic
cp Bulgarian.nameToUnicode KOI8-R.unicodeMap /usr/share/xpdf/cyrillic
cat add-to-xpdfrc >> /etc/xpdfrc

If needed, edit /etc/xpdfrc and change paths /usr/local/share/xpdf/cyrillic/ to paths /usr/share/xpdf/cyrillic/.

If you want to have access to ghostscript fonts, edit /etc/xpdfrc and uncomment lines which start with displayFontT1 and change the paths to ghostscript fonts as appropriate (on Debian it is /usr/share/fonts/type1/gsfonts/).

TeX

I use teTeX (version 2.0.2) distribution. In this section, $TEXMF stands for the path to your teTeX distribution (usually /usr/share/texmf/). I describe how to setup Cyrillic support for use with Plain TeX, both for TeX and pdfTeX. I do not describe how to use Cyrillic in LaTeX -- it is well documented elsewhere.

Note that I describe how to build the required formats manually, which should work on most systems. However, some distributions provide tools which make life easier by running low-level commands automatically. For instance, in teTeX 2.0.2 there is a texconfig(1) configuration tool; many configuration files are centralized in /etc/texmf/ (see update-updmap(8), update-texmf(8), update-fmtutil(8)). After (re)configuring formats, you can run fmtutil(8), instead of manually running initex(1).

  1. Cyrillic fonts
    1. I use two Cyrillic font packages in addition to the ones that come with teTeX distribution, that is, PSCyr and Literat fonts downloadable from

      ftp://mch5.chem.msu.su/pub/russian/psfonts/
      ftp://ftp.vsu.ru/pub/tex/font-packs/pscyr/
      ftp://ftp.vsu.ru/pub/tex/literat.zip
      ftp://ftp.vsu.ru/pub/tex/literat-*.tar.gz
      

      If you install these fonts, make sure that references to map files for the new fonts are added to extra_modules variable in $TEXMF/dvips/config/updmap (or /etc/texmf/dvips/, /etc/texmf/updmap.d/ on newer systems).

      In case of $TEXMF/dvips/config/updmap, add

      extra_modules="
        tli.map
        pscyr.map
        txr.map
      "
      

      for Literat, PSCyr and TXfonts packages respectively (the last one comes with teTeX). If your updmap does not already have the map file for Cyrillic Computer Modern (cmcyr.map) listed in common_modules variable, you can include it in extra_modules as well.

      In case your system uses /etc/texmf/ hierarchy, add map files to /etc/texmf/dvips and put something like

      Map  tli.map
      Map  pscyr.map
      Map  txr.map
      
      into /etc/texmf/updmap.d/, in a file, e.g., 10mymaps.cfg, then run update-updmap(8).
    2. if you want to use Type1 fonts by default when both Type1 and Metafont versions are available (a good idea if you want to produce PDF documents), make sure $TEXMF/dvips/config/updmap contains the line

      type1_default=true
      

      and rerun updmap. If your system uses /etc/texmf/updmap.d/00updmap.cfg instead, check that it contains a line `dvipsPreferOutline true' and run update-updmap(8).

  2. CyrPlain
    1. install Babel and ruhyphen (or ukrhyph for Ukrainian), if not yet (pre)installed;
    2. edit $TEXMF/tex/generic/config/language.dat and make sure the following line(s) is uncommented (for Ukrainian, choose the line with your encoding):

      russian ruhyphen.tex
      ukrainian ukrhyph.t2a
      
    3. edit $TEXMF/tex/generic/ruhyphen/ruhyphen.tex and select appropriate font encoding and hyphenation scheme (you can also select hyphenation scheme later in $TEXMF/tex/cyrplain/config/cyrtex.cfg); the same goes for $TEXMF/tex/generic/ukrhyph/ukrhyph.tex;
    4. edit $TEXMF/tex/cyrplain/config/cyrtex.cfg. Select fonts and font encoding. For example, for cmcyr fonts in T2A encoding, add

      \c wcm/t2a/txxdefs/cm/cyrcmfnt
      

      and for cmcyr fonts in LCY encoding, add

      \c xcm/lcy/txxdefs/cm/cyrcmfnt
      

      Select hyphenation scheme (if you have not yet done so in 2.c), default input encoding for your documents, and whether you want to be able to switch input encodings:

      \def\Pattern{ct}
      \let\ifinpenc\iftrue
      \def\definpenc{koi8-r}
      
    5. For Ukrainian, you can also define language switch command at the end of $TEXMF/tex/cyrplain/base/cyrtex.tex:

      \def\Ukrainian{\set@hyphenmins22\language\l@ukrainian}\let\Ukr\Ukrainian
      
    6. build cyrtex.fmt with the command

      tex --ini --fmt=cyrtex --progname=tex cyrtex.ini
      

      and either place it in $TEXMF/web2c or make a link to it from there;

    7. run texhash.
    8. To use Cyrillic in your Plain TeX documents, either place

      %&cyrtex
      

      in the very first column of the very first line of your document, or run tex with parameters `tex --fmt cyrtex --translate-file=cp8bit'. Then, to select input and font encodings for you document, use for example

      \inputencoding{koi8-r}
      \fontencoding{T2A}
      

      Note that cmcyr fonts do not contain Ukrainian glyphs. You can load other Cyrillic fonts, for example, Literat (see Cyrillic fonts for installation). At the beginning of your document, type

      \font\tenrm=tlir6a  at 10pt
      \font\tenbf=tlib6a  at 10pt
      \font\tenit=tliri6a at 10pt
      \font\tensl=tliro6a at 10pt
      \rm
      

      to replace the basic 10pt fonts.

  3. pdfTeX

    The following works for pdfTeX version 3.14159-1.00a-pretest-20011114-ojmw (Web2C 7.3.7).

    First, setup CyrPlain. Then:

    1. build cyrpdftex with the command

      pdftex --ini --fmt=cyrpdftex cyrtex.ini
      

      and either place it in $TEXMF/web2c or make a link to it from there;

    2. in $TEXMF/web2c/texmf.cnf, add the line

      TEXINPUTS.cyrpdftex   = .;$TEXMF/{pdftex,tex}/{plain,generic,}//
      
    3. if you want to insert figures in your documents, build mptopdf.efmt (for pdfeTeX) and/or mptopdf.fmt (for pdfTeX) with the commands

      pdftex --ini mptopdf
      pdfetex --ini mptopdf
      

      and either place them in $TEXMF/web2c or make links to them from there (use mpost to produce postscript figures, then mptopdf to convert them into pdf figures; now you can insert them into your pdfTeX document -- see documentation);

    4. texhash;
    5. if pdftex throws the following warnings at you:

      Warning: pdftex (file /home/oleg/texmf/dvips/config/pdftex.map): invalid entry
      for `rtxphvbo': SlantFont/ExtendFont can be used only with embedded T1 fonts
      
      Warning: pdftex (file /home/oleg/texmf/dvips/config/pdftex.map): invalid entry
      for `rtxphvro': SlantFont/ExtendFont can be used only with embedded T1 fonts
      
      Warning: pdftex (file /home/oleg/texmf/dvips/config/pdftex.map): invalid entry
      for `rtxptmbo': SlantFont/ExtendFont can be used only with embedded T1 fonts
      
      Warning: pdftex (file /home/oleg/texmf/dvips/config/pdftex.map): invalid entry
      for `rtxptmro': SlantFont/ExtendFont can be used only with embedded T1 fonts
      

      you can edit $TEXMF/dvips/config/pdftex.map and replace the following lines

      rtxphvbo Helvetica-Bold ".167 SlantFont TeXBase1Encoding ReEncodeFont" <tx8r.enc
      rtxphvro Helvetica ".167 SlantFont TeXBase1Encoding ReEncodeFont" <tx8r.enc
      rtxptmbo Times-Bold ".167 SlantFont TeXBase1Encoding ReEncodeFont" <tx8r.enc
      rtxptmro Times-Roman ".167 SlantFont TeXBase1Encoding ReEncodeFont" <tx8r.enc
      

      with this:

      rtxphvbo Helvetica-Bold "TeXBase1Encoding ReEncodeFont" <tx8r.enc
      rtxphvro Helvetica "TeXBase1Encoding ReEncodeFont" <tx8r.enc
      rtxptmbo Times-Bold "TeXBase1Encoding ReEncodeFont" <tx8r.enc
      rtxptmro Times-Roman "TeXBase1Encoding ReEncodeFont" <tx8r.enc
      
  4. dvips

    This is not really about Cyrillic, but anyway.

    If you want dvips to output to a file by default but not to lpr, edit $TEXMF/dvips/config/config.ps and comment out the line

    o |lpr
    

    If you want to add unsupported papersize to dvips, for instance a5, add the following lines to $TEXMF/dvips/config/config.ps:

    @ a5 148.5mm 209.9mm
    @+ ! %%DocumentPaperSizes: a5
    @+ %%BeginPaperSize: a5
    @+ a5
    @+ %%EndPaperSize
    

    Just remember that this makes you document not portable (for compilation, not viewing) to systems which do not have this definition in their config.ps.


Mouse

The main problem with the mouse is that gpm(8) (text console mouse driver) and X Window do not work together very well. To make them behave, you can instruct gpm to repeat mouse commands on a device file, and X Window to read the commands from that device file.

I used the following setup for my mouse (A4 Tech three button mouse, with wheel). For other mice you might need to choose different mouse type for gpm. See man 8 gpm.

  1. Instruct gpm to run as repeater by adding the following to /etc/gpm.conf:

    repeat_type=raw
    type=imps2
    
  2. If you want to paste by right button instead of middle button, add the following line to /etc/gpm.conf:

    append=" -2 "
    
  3. Restart gpm (`/etc/init.d/gpm restart' as root).
  4. In /etc/X11/XF86Config-4, change settings in InputDevice section for your mouse:

    Option      "Buttons"         "5"
    Option      "Protocol"        "IMPS/2"
    Option      "Device"          "/dev/gpmdata"
    Option      "ZAxisMapping"    "4 5"
    
  5. If you want to be able to paste by Right+Left button press, add the following line to your /etc/X11/XF86Config-4:

    Option      "Emulate3Buttons" "yes"
    

Sound

Build kernel with appropriate driver included. If you choose it to be built as a module, then add to /etc/modules.conf (in Debian, edit files in /etc/modutils and run update-modules(8)), assuming the name of the driver for your sound card is emu10k1 (see /lib/modules/2.4.XX/kernel/drivers/sound):

alias sound-slot-0 emu10k1

You may also need to add (for the mixer):

alias sound-service-0-0 emu10k1

Network card

If you build the driver as a module, add to /etc/modules.conf (in Debian, edit files in /etc/modutils and run update-modules(8)), assuming that the name of the driver is ne (see /lib/modules/2.4.XX/kernel/drivers/net):

alias eth0 ne

You may also need to add the following for (ISA) cards:

options ne io=0xXXX irq=XX

Main page