LDP/LDP/howto/docbook/Config-HOWTO.sgml

3769 lines
87 KiB
Plaintext

<!DOCTYPE Article PUBLIC "-//OASIS//DTD DocBook V3.1//EN">
<!--
Configuration HOWTO, by Guido Gonzato, <ggonza@tin.it>
written with jed and docbook mode
(http://ibogeo.df.unibo.it/guido/jed.html)
-->
<article>
<artheader>
<title>Configuration HOWTO</title>
<author>
<firstname>Guido</firstname>
<othername>``goccia''</othername>
<surname>Gonzato</surname>
<affiliation>
<address>
<email>ggonza@tin.it</email>
</address>
</affiliation>
</author>
<pubdate>
Version 1.99.7. 6 November 2001.
</pubdate>
<revhistory>
<revision>
<revnumber>v1.99.7</revnumber>
<date>2001-11-06</date>
<authorinitials>gg</authorinitials>
<revremark>
Updated and fixed DocBook tags.
</revremark>
</revision>
<revision>
<revnumber>v1.99.6</revnumber>
<date>2000-08-31</date>
<authorinitials>gg</authorinitials>
<revremark>
</revremark>
</revision>
</revhistory>
<abstract>
<para>
This HOWTO aims at making the fine--tuning of your newly installed Linux
box quicker and easier. Here you will find a set of configuration tips
for the most common applications and services.
</para>
</abstract>
</artheader>
<!-- Introduction -->
<sect1 id="Introduction">
<title>Introduction</title>
<!-- Why -->
<sect2>
<title>Why This HOWTO</title>
<para>
Current distributions are approaching perfection, but some fine-tuning is
still needed. Many new users are intimidated by the apparent complexity of
a Linux system, and as a result I note that the same questions crop up on
c.o.l.setup over and over again. To try and remedy this situation, and for
my own convenience, I wrote a to--do list that eventually became this
HOWTO. Here you will find configuration tips and examples for the most
common applications, programs, and services, which should save you a fair
amount of time and work.
</para>
<para>
I realise that this HOWTO is quite RedHat-centric. Currently, I only have
access to Red Hat and Mandrake machines, kernels ranging from 2.0.36 to
2.2.15; so don't take any of my tips as gospel if you have other
distributions. Previous versions of this HOWTO provided some information
for SuSE, Debian and Caldera; but as I no longer have access to those
machines, I can't keep the details up-to-date. No information is better
that inaccurate information, so it's up to you to to adapt my tips to your
distribution.
</para>
<para>
This HOWTO can't replace others, and it's not meant to. Reading docs and
HOWTOs always pays, so you're strongly advised to do so if you want to
know more. Also, no spoon--feeding here: if you realise you don't
understand something, please refer to the relevant HOWTO. Let me remind
you that the right place for seeking help with Linux configuration is
Usenet, i.e. <ulink URL="news:comp.os.linux.setup">
<citetitle>news:comp.os.linux.setup</citetitle></ulink>.
<emphasis>Please</emphasis>, don't seek help from me because I'm quite
overloaded.
</para>
<para>
The official place for this document, which also hosts all other HOWTOs I
refer to and some translations, is <ulink
URL="http://www.linuxdoc.org"><citetitle>http://www.linuxdoc.org
</citetitle></ulink>.
</para>
</sect2>
<!-- What -->
<sect2>
<title>What We Will Be Configuring</title>
<para>
There can be endless hardware configurations for a PC, but in my
experience one is quite common: a PC fitted with a large HD split into
three partitions (one for DOS/Windows, one for Linux, one for the swap),
sound card, modem, CD-ROM drive, printer, mouse. A parallel port Zip Drive
is also very common. This machine is possibly part of a mixed
Windows-Linux network, where it acts as server.
</para>
<para>
This is the hardware I'll assume you want to configure, but it's easy to
adapt the following tips to different configurations. It's implicitly
assumed that you'll be root when editing/fixing/hacking.
</para>
<para>
And now, lads, sleeves up.
</para>
</sect2>
</sect1>
<!-- General System Setup -->
<sect1>
<title>General System Setup</title>
<!-- Security -->
<sect2>
<title>A Few Words About Security</title>
<para>
Even before your system boots, you should decide what level of security
you want to implement. To begin with, don't connect your machine to the
network until you have decided what to do.
</para>
<para>
Security is a vast subject that goes beyond the scope of this HOWTO; two
good starting points are the Linux Security Administrator's Guide <ulink
URL="http://www.securityportal.com/lasg"><citetitle>
http://www.securityportal.com/lasg</citetitle></ulink> and the Linux
Security Guide <ulink
URL="http://nic.com/~dave/SecurityAdminGuide/index.html">
<citetitle>http://nic.com/~dave/SecurityAdminGuide/index.html
</citetitle></ulink>. You should consider at least the following steps:
using shadow passwords (Shadow Password HOWTO), restricting network access
to the machine (Section <XRef LinkEnd="Restricting">), using the Secure
Shell (<ulink
URL="http://www.openssh.org"><citetitle>http://www.openssh.org
</citetitle></ulink>) or the Secure Remote Password (<ulink
URL="http://srp.stanford.edu/srp/"><citetitle>
http://srp.stanford.edu/srp/</citetitle></ulink>). Good luck.
</para>
</sect2>
<!-- Logbook -->
<sect2>
<title>Start the Logbook!</title>
<para>
To keep your installation in shape, it's <emphasis>essential</emphasis>
that you know exactly what happened to your machine, which packages you
installed that day, what you removed or modified, and so on. So, the first
thing you'll do before you tamper with your machine is start a
``logbook''. Therein you'll take note of <emphasis>every</emphasis> move
you make as root; in my own logbook I also keep a section where I list all
modified system files, additional .rpms, and .tar.gz I installed.
Optimally, backtracking your moves you should be able to re-obtain a fresh
installation.
</para>
<para>
Make a backup copy of the system files you touch. Better still, use RCS;
you'll be able to backtrack all changes. Never work as root without
logging your moves!
</para>
</sect2>
<!-- Keyboard -->
<sect2>
<title>Keyboard</title>
<para>
If you missed this step during installation or have changed your keyboard,
you'll have to:
</para>
<para>
<itemizedlist>
<listitem>
<para>
look for a suitable key table starting from
<filename>/usr/lib/kbd/keymaps/i386</filename>; for example,
<filename>querty/it-latin1.kmap.gz</filename> supports the Italian keyboard;
</para>
</listitem>
<listitem>
<para>
edit the file <filename>/etc/sysconfig/keyboard</filename> so as it reads:
<filename>KEYTABLE="it-latin1"</filename>;
</para>
</listitem>
<listitem>
<para>
to set up the keyboard repeat rate and delay time, add this line to
<filename>/etc/rc.d/rc.sysinit</filename>:
<screen>
/sbin/kbdrate -s -r 16 -d 500 # or whatever you like
</screen>
</para>
</listitem>
</itemizedlist>
</para>
<para>
To load the key table, issue
</para>
<screen>
/etc/rc.d/init.d/keytable start
</screen>
<para>
Other special keys will be dealt with in the following sections. To enable
NumLock on by default, add these lines to
<filename>/etc/rc.d/rc.sysinit</filename>:
</para>
<screen>
for tty in /dev/tty[1-9]*; do
setleds -D +num &#60; $tty
done
</screen>
<para>
Normally, the Linux console cannot distinguish between, say, Arrow and
Shift-arrow, but some applications (namely, the editor <XRef
LinkEnd="jed">) do. Normally, these key bindings are only available in
xterm. The following key map, which you can choose to load at boot time,
is very handy:
</para>
<screen>
# Load this key map with: loadkey shift.map
# Shift + Up
shift keycode 103 = F100
string F100 = "\033[a"
# Shift + Left
shift keycode 106 = F101
string F101 = "\033[c"
# Shift + Right
shift keycode 105 = F102
string F102 = "\033[d"
# Shift + Down
shift keycode 108 = F103
string F103 = "\033[b"
# Ctrl + Ins
control keycode 110 = F104
string F104="\033[2^"
# Shift + Ins
shift keycode 110 = F105
string F105="\033[2$"
# Shift + PgUp
shift keycode 104 = F106
string F106 = "\033[5$"
# Shift + PgDn
shift keycode 109 = F107
string F107 = "\033[6$"
# Shift + Home
shift keycode 102 = F108
string F108 = "\033[1$"
# Shift + End
shift keycode 107 = F109
string F109 = "\033[4$"
# Shift + Del
shift keycode 111 = F110
string F110 = "\033[3$"
# Ctrl + Del
control keycode 111 = F111
string F111 = "\033[3^"
</screen>
</sect2>
<!-- Rescue Floppy -->
<sect2>
<title>Boot and Rescue Floppy</title>
<para>
Make a couple of boot floppies for your newly installed system. Your
distribution may include a command for creating such a floppy (say,
<filename>mkbootdisk</filename> or something like that); if not, these
commands will do:
</para>
<para>
<screen>
#~ dd if=/boot/vmlinuz-2.0.36-0.7 of=/dev/fd0 # use your kernel image
#~ rdev /dev/fd0 /dev/hda2 # your Linux root partition
</screen>
</para>
<para>
Also, have at least a couple of rescue disks ready. There's a wide choice
of rescue disks at <ulink
URL="ftp://metalab.unc.edu/pub/Linux/system/recovery"><citetitle>
ftp://metalab.unc.edu/pub/Linux/system/recovery </citetitle></ulink>; if
you don't know which one to choose, I suggest you try out Tomsbtrt, whose
home page is <ulink
URL="http://www.toms.net/rb"><citetitle>http://www.toms.net/rb
</citetitle></ulink>. It's very complete, but some utilities seem missing
at first; for example, <filename> ftp</filename> is not there but you get
<filename>nc</filename> (netcat) instead. Please read its documentation.
</para>
</sect2>
<!-- Console -->
<sect2 id="console">
<title>Console Colours</title>
<para>
Why stick to white on black in Linux console? With the
<command>setterm</command> command you can choose nicer combinations:
</para>
<screen width="80">
setterm -background blue -foreground red -bold on -store
</screen>
<para>
Type <command>setterm</command> alone for a list of arguments.
</para>
</sect2>
<!-- Kernel -->
<sect2>
<title>Kernel Matters</title>
<para>
IMHO, the first thing to do next is build a kernel that best suits your
system. It's very simple to do but, in any case, refer to the
<filename>README</filename> file in <filename>/usr/src/linux/</filename>
or the Kernel HOWTO. Hints:
</para>
<para>
<itemizedlist>
<listitem>
<para>
consider carefully your needs. Choosing a kernel configuration, applying
the patches, and compiling it once and for all is more productive than
reconfiguring and recompiling each month; this is especially true if your
Linux box is a server. Don't forget to include support for all the
hardware you might likely add in the future (e.g. SCSI, Zip, network
cards, etc); using modules is usually the best choice;
</para>
</listitem>
<listitem>
<para>
notebook users: if you plan to use a PCMCIA modem/fax, remember to compile
serial support <emphasis>in the kernel</emphasis>. Don't compile it as a
module, as this would need more complex configuration;
</para>
</listitem>
<listitem>
<para>
remember to compile everything you need; i.e., don't forget the pcmcia
modules, or the ALSA sound drivers;
</para>
</listitem>
<listitem>
<para>
to save time the next time you reconfigure and recompile the kernel, it's
a good idea to save your configuration on a file and keep it in a safe
place. If you upgrade the kernel and use ``make oldconfig'', your old
config file will be taken and any not included features will be prompted
whether they should be included, resulting in a new, upgraded config file.
</para>
</listitem>
</itemizedlist>
</para>
</sect2>
<!-- HD -->
<sect2>
<title>Hard Disk Performance</title>
<para>
Your (E)IDE hard disk's performance can be greatly enhanced by
<emphasis>carefully</emphasis> using <filename>hdparm</filename>(8). If
your Linux distribution doesn't include it, you'll find on <ulink
URL="ftp://metalab.unc.edu/pub/Linux/system/hardware"><citetitle>
ftp://metalab.unc.edu/pub/Linux/system/hardware </citetitle></ulink>; look
for a file called <filename>hdparm-X.Y.tar.gz</filename>.
</para>
<para>
Since many details depend on your hard disk and HD controller, I can't
give you a general recipe. You risk to toast your filesystem, so
<emphasis>read the man page carefully</emphasis> before using some of the
options. At its simplest, you could add the following line to
<filename>/etc/rc.d/rc.sysinit</filename>:
</para>
<para>
<screen>
/sbin/hdparm -c1 /dev/hda # first IDE drive assumed
</screen>
</para>
<para>
which enables (E)IDE 32-bit I/O support. As for the
`<filename>-m</filename>' option, this is what <filename>hdparm</filename>
author Mark Lord emailed me:
</para>
<para>
<QUOTE> (...) if your system uses components from the past couple of years
&lsqb;&#60; 1997], it will be fine. Older than that, there *may* be a
problem (unlikely). The really buggy chips were the CMD0646 and RZ1000
chips, used *extensively* on 486 and (early) 586 motherboards about 2-3
years ago.
</QUOTE>
</para>
<para>
For recent machines, these settings should work fine:
</para>
<para>
<screen>
/sbin/hdparm -c1 -A1 -m16 -d1 /dev/hda
</screen>
</para>
</sect2>
<!-- Zip drive -->
<sect2>
<title>Parallel Port Zip Drive</title>
<para>
Stock kernels include the driver for both old (ppa) and new (imm) Zip
drives. If you recompile the kernel, make sure that SCSI support and SCSI
disk support are enabled. Remember, there can be conflicts between the
printer and the Zip drive on the same parallel port, so you have better
use kernel modules.
</para>
<para>
Zip disks are sold preformatted on partition
<filename>/dev/sda4</filename>. To enable the Zip, append this to
<filename>/etc/rc.d/rc.sysinit</filename>:
</para>
<para>
<screen>
# Enable the Zip drive
/sbin/modprobe ppa # imm for recent models
</screen>
</para>
<para>
Zip disks can be mounted via <filename>/etc/fstab</filename> as shown
below, or via Mtools adding this line to your
<filename>/etc/mtools.conf</filename>:
</para>
<para>
<screen>
drive z: file="/dev/sda4" exclusive
</screen>
</para>
<para>
besides, the command <filename>mzip</filename> allows you to eject, query
the status, write and password protect Zip disks; <filename>man
mzip</filename> for details. The Mtools home page is at <ulink
URL="http://linux.wauug.org/pub/knaff/mtools"><citetitle>
http://linux.wauug.org/pub/knaff/mtools</citetitle></ulink>.
</para>
</sect2>
<!-- Device drivers -->
<sect2>
<title>Device Drivers</title>
<para>
Devices in <filename>/dev</filename> (or better, links to the actual
device drivers) may be missing. Check what devices your mouse, modem, and
CD--ROM drive correspond to, then do what follows:
</para>
<para>
<screen>
~# cd /dev
/dev# ln -s ttyS0 mouse; ln -s ttyS1 modem; ln -s hdb cdrom; ln -s sda4 zip
</screen>
</para>
<para>
In most notebooks the mouse device is <filename>/dev/psaux</filename>:
take this into account when configuring X11. If you wish, do
<filename>chmod 666</filename> to these devices to make them fully
accessible by every user.
</para>
</sect2>
<!-- Sound card -->
<sect2>
<title>Sound Card</title>
<para>
My desktop PC is fitted with an old Sound Blaster 16; even if you've got
something different, you may take what follows as guidelines.
</para>
<para>
I compiled the sound card support as a module (<filename>sb.o</filename>).
Then I put this in <filename>/etc/conf.modules</filename>:
</para>
<para>
<screen>
options sb io=0x220 irq=5 dma=1 dma16=5 mpu_io=0x330
alias sound sb
</screen>
</para>
<para>
To enable the sound, make sure that <filename>modprobe sound</filename> is
invoked in <filename>/etc/rc.d/rc.sysinit</filename>. Alternatively, get the
tool <filename>sndconfig</filename> from the RedHat site.
</para>
<para>
Besides the standard kernel sound drivers, the Alsa drivers (<ulink
URL="http://www.alsa-project.org"><citetitle>
http://www.alsa-project.org</citetitle></ulink>) are an excellent choice.
Strangely, though, the sound channels are muted by default. You'll want to
use <filename>aumix</filename> and this <filename>/etc/aumixrc</filename>
to set the volume to 100&percnt;:
</para>
<para>
<screen>
vol:100:100:P
synth:100:100:P
pcm:100:100:P
line:100:100:P
mic:100:100:R
cd:100:100:P
</screen>
</para>
</sect2>
<!-- Login messages -->
<sect2>
<title>Login Messages</title>
<para>
If you wish to customise the login messages, check whether your
<filename>/etc/rc.d/rc.local</filename> overwrites
<filename>/etc/issue</filename> and <filename>/etc/motd</filename>.
(RedHat does.) If so, get on with your editor.
</para>
<para>
If you'd like a colourised login message, you may adapt your
<filename>rc.local</filename> inserting lines like these:
</para>
<para>
<screen>
# put a real escape character instead of ^[. To do this:
# emacs: ^Q ESC vi: ^V ESC joe: ` 0 2 7 jed: ` ESC
ESC="^[" # a real escape character
BLUE="$ESC[44;37m"
NORMAL="$ESC[40;37m"
CLEAR="$ESC[H$ESC[J"
> /etc/issue
echo "$CLEAR" >> /etc/issue
echo "$BLUE Welcome to MyServer (192.168.1.1) " >> /etc/issue
echo "$NORMAL " >> /etc/issue
echo "" >> /etc/issue
</screen>
</para>
</sect2>
<!-- Hostname -->
<sect2 id="Hostname">
<title>Hostname </title>
<para>
Issuing the command <filename>hostname
new_host_name</filename> may not be enough. To avoid the
dreaded <filename>sendmail</filename> lock, follow these steps (only valid
for a stand--alone machine):
</para>
<para>
<itemizedlist>
<listitem>
<para>
edit <filename>/etc/sysconfig/network</filename> and change the hostname
therein (e.g. <filename>new_host_name.your_domain</filename>);
</para>
</listitem>
<listitem>
<para>
edit <filename>/etc/HOSTNAME</filename> appropriately;
</para>
</listitem>
<listitem>
<para>
append the new hostname in the line in <filename>/etc/hosts</filename>:
<screen>
127.0.0.1 localhost new_host_name.your_domain
</screen>
</para>
</listitem>
</itemizedlist>
</para>
</sect2>
<!-- Mouse -->
<sect2>
<title>Mouse</title>
<para>
<filename>gpm</filename> mouse services are useful to perform cut and
paste in tty mode, and to use the mouse in some applications. Make sure
that you have a file called <filename>/etc/sysconfig/mouse</filename> and
that it reads:
</para>
<para>
<screen>
MOUSETYPE="Microsoft"
XEMU3=yes
</screen>
</para>
<para>
Moreover, you must have a file <filename>/etc/rc.d/init.d/gpm</filename>, where
you'll put additional command line parameters. Mine reads:
</para>
<para>
<screen>
...
daemon gpm -t $MOUSETYPE -d 2 -a 5 -B 132 # two-button mouse
...
</screen>
</para>
<para>
Obviously, make sure this configuration is right for your mouse type. In
most notebooks, <filename>MOUSETYPE</filename> is
``<filename>PS/2</filename>''.
</para>
<para>
If you like to use menus in console with Ctrl-button, then configure
<filename>gpm-root</filename>. Edit the default menu in
<filename>/etc/gpm-root.conf</filename>, then launch
<filename>gpm-root</filename> from
<filename>/etc/rc.d/rc.local</filename>.
</para>
</sect2>
<!-- Mount points -->
<sect2>
<title>Mount Points</title>
<para>
It's handy to have mount points for the floppy, other devices and
NFS-exported directories. For example, you can do the following:
</para>
<para>
<screen>
~# cd /mnt; mkdir floppy cdrom win zip server
</screen>
</para>
<para>
This creates mount points for a DOS/Win floppy, the CD--ROM, the Windows
partition, the parallel port Zip drive, and an NFS directory.
</para>
<para>
Now edit the file <filename>/etc/fstab</filename> and add the following
entries:
</para>
<para>
<screen>
/dev/fd0 /mnt/floppy auto user,noauto 0 1
/dev/cdrom /mnt/cdrom iso9660 ro,user,noauto 0 1
/dev/zip /mnt/zip vfat user,noauto,exec 0 1
/dev/hda1 /mnt/win vfat user,noauto 0 1
server:/export /mnt/server nfs defaults
</screen>
</para>
<para>
Obviously, you must use the correct device in the first field.
</para>
<para>
Note the `auto' filesystem type in the first line; it allows you to mount
both ext2 and vfat (DOS/Windows) floppies, but you need a recent version
of <filename>mount</filename>. You may find <filename>mtools</filename>
more convenient.
</para>
</sect2>
<!-- Automount -->
<sect2>
<title>Automount Points</title>
<para>
If you don't like the mounting/unmounting thing, consider using
<filename>autofs</filename>(5). You tell the autofs daemon what to
automount and where starting with a file,
<filename>/etc/auto.master</filename>. Its structure is simple:
</para>
<para>
<screen>
/misc /etc/auto.misc
/mnt /etc/auto.mnt
</screen>
</para>
<para>
In this example you tell autofs to automount media in <filename>/misc</filename>
and <filename>/mnt</filename>, while the mountpoints are specified
in<filename>/etc/auto.misc</filename> and <filename>/etc/auto.mnt</filename>. An example
of <filename>/etc/auto.misc</filename>:
</para>
<para>
<screen>
# an NFS export
server -ro my.buddy.net:/pub/export
# removable media
cdrom -fstype=iso9660,ro :/dev/hdb
floppy -fstype=auto :/dev/fd0
</screen>
</para>
<para>
Start the automounter. From now on, whenever you try to access the
inexistent mount point <filename>/misc/cdrom</filename>, il will be
created and the CD-ROM will be mounted.
</para>
</sect2>
<!-- LILO -->
<sect2>
<title>lilo(8) and LOADLIN.EXE</title>
<para>
Many users run both Linux and DOS/Windows on their PC, and want to choose
at boot time which os to use; this should be done at install time, but in
case, do what follows. Let's suppose that <filename>/dev/hda1</filename>
contains DOS/Windows and that <filename>/dev/hda2</filename> contains Linux.
</para>
<para>
<screen>
~# fdisk
Using /dev/hda as default device!
Command (m for help):a
Partition number (1-4): 2
Command (m for help):w
~#
</screen>
</para>
<para>
This makes the Linux partition bootable. Then write this basic
<filename>/etc/lilo.conf</filename> file:
</para>
<para>
<screen>
boot = /dev/hda2
compact # may conflict with "linear"
delay = 100 # 10 seconds
linear # gets rid of the "1024 cylinder" problem
#lba32 # alternative
message = /boot/bootmesg.txt # write your own, if you will
root = current
image = /boot/vmlinuz # boot linux by default as this entry comes first
label = linux
read-only
# append="mem=128M" # to see more memory than 64M
other = /dev/hda1
table = /dev/hda
label = win
</screen>
</para>
<para>
Now issue <filename>/sbin/lilo</filename> and you're done. Being
<filename>lilo</filename> a crucial part of your installation, you're
strongly advised to read its documentation anyway.
</para>
<para>
To boot Linux from DOS/Windows without resetting, put
<filename>LOADLIN.EXE</filename> in a directory (in the DOS partition!)
included in the DOS path; then copy your kernel to, say,
<filename>C:&bsol;TEMP&bsol;VMLINUZ</filename>. The following simple
<filename>.BAT</filename> file will boot Linux:
</para>
<para>
<screen>
rem linux.bat
smartdrv /C
loadlin c:\temp\vmlinuz root=/dev/hda2 ro
</screen>
</para>
<para>
If you use Windows 9x, set the properties of this
<filename>.BAT</filename> so as it starts in MS--DOS mode.
</para>
<!-- Security tip -->
<sect3>
<title>Security Tip</title>
<para>
Making a backup copy of your MBR before installing Linux is a safe move.
Prepare a Windows rescue floppy, and make sure it includes
<filename>FDISK.EXE</filename>. To restore the MBR, all you have to do is
</para>
<para>
<screen>
A:\> fdisk /mbr
</screen>
</para>
</sect3>
</sect2>
<!-- Printer -->
<sect2>
<title>Printer Configuration (lpd)</title>
<para>
All distributions I know have a configuration tool for setting up the
printer (<filename>printtool</filename>, <filename>yast</filename>, or
<filename>magicfilter</filename>); if you don't have it, this is a basic
manual configuration.
</para>
<para>
Let's suppose you have a non--PostScript (non ``Windows-only'' too!)
printer you want to use to print raw text (e.g., C source files) and
PostScript files via Ghostscript, which is assumed to be already
installed.
</para>
<para>
Setting up the printer involves a few steps:
</para>
<para>
<itemizedlist>
<listitem>
<para>
find out which one the parallel print device is: try
<screen>
~# echo "hello, world" > /dev/lp0
~# echo "hello, world" > /dev/lp1
</screen>
and take note which one works.
</para>
</listitem>
<listitem>
<para>
make two spool directories:
<screen>
~# cd /var/spool/lpd
/var/spool/lpd/# mkdir raw; mkdir postscript
</screen>
</para>
</listitem>
<listitem>
<para>
if your printer exibits the ``staircase effect'' (most inkjets do), you'll
need a filter. Try to print two lines with
<screen>
~# echo "first line" > /dev/lp1 ; echo "second line" > /dev/lp1
</screen>
if the output is like this:
<screen>
first line
second line
</screen>
then save this script as <filename>/var/spool/lpd/raw/filter</filename>:
<screen>
#!/bin/sh
# This filter eliminates the "staircase effect"
awk '{print $0, "\r"}'
</screen>
and make it executable with <filename>chmod 755
/var/spool/lpd/raw/filter</filename>.
</para>
</listitem>
<listitem>
<para>
make a filter for PostScript emulation. Write the following filter as
<filename>/var/spool/lpd/postscript/filter</filename>:
<screen>
#!/bin/sh
DEVICE=djet500
RESOLUTION=300x300
PAPERSIZE=a4
SENDEOF=
nenscript -TUS -ZB -p- |
if [ "$DEVICE" = "PostScript" ]; then
cat -
else
gs -q -sDEVICE=$DEVICE \
-r$RESOLUTION \
-sPAPERSIZE=$PAPERSIZE \
-dNOPAUSE \
-dSAFER \
-sOutputFile=- -
fi
if [ "$SENDEOF" != "" ]; then
printf "\004"
fi
</screen>
(in this example an HP DeskJet printer is assumed. Adapt it to your
printer).
</para>
</listitem>
<listitem>
<para>
finally, add the following entries in <filename>/etc/printcap</filename>:
<screen>
# /etc/printcap
lp|ps|PS|PostScript|djps:\
:sd=/var/spool/lpd/postscript:\
:mx#0:\
:lp=/dev/lp1:\
:if=/var/spool/lpd/postscript/filter:\
:sh:
raw:\
:sd=/var/spool/lpd/raw:\
:mx#0:\
:lp=/dev/lp1:\
:if=/var/spool/lpd/raw/filter:\
:sh:
</screen>
</para>
</listitem>
</itemizedlist>
</para>
<para>
For more complex or exotic printing configurations, the Printing-HOWTO
awaits you.
</para>
<para>
If you use <filename>printtool</filename>, be aware that the GSDEVICE
chosen by Printtool will work, but not necessarily at its best for your
printer. You may consider fiddling a bit with the file
<filename>postscript.cfg</filename>; for instance, I changed GSDEVICE from
<filename>cdj500</filename> to <filename>djet500</filename> and now my
prints come out much quicker.
</para>
</sect2>
<!-- SVGATextMode -->
<sect2 id="SVGA">
<title>SVGATextMode </title>
<para>
This utility, available on <ulink
URL="ftp://tsx-11.mit.edu/pub/linux/sources/sbin"><citetitle>
ftp://tsx-11.mit.edu/pub/linux/sources/sbin</citetitle></ulink>, is useful
for changing the console screen resolution, font, and cursor shape. Users
whose language include accented characters will be able to use them in
console applications, while notebook users may change the cursor shape to
make it more visible.
</para>
<para>
Edit <filename>/etc/TextConfig</filename> or
<filename>/etc/TextMode</filename>, starting with the default VGA
definition. Europeans should be happy with this ``LoadFont'' section:
</para>
<para>
<screen>
Option "LoadFont"
FontProg "/usr/bin/setfont"
FontPath "/usr/lib/kbd/consolefonts"
FontSelect "lat1u-16.psf" 8x16 9x16 8x15 9x15
FontSelect "lat1u-14.psf" 8x14 9x14 8x13 9x13
FontSelect "lat1u-12.psf" 8x12 9x12 8x11 9x11
FontSelect "lat1u-08.psf" 8x8 9x8 8x7 9x7
</screen>
</para>
<para>
Once you're done, try your configuration with a command like
<filename>SVGATextMode "80x34x9"</filename>, and if everything appears to
be working fine, remove the warnings from
<filename>/etc/TextMode</filename> and include this line in
<filename>etc/rc.d/rc.sysinit</filename>:
</para>
<para>
<screen>
# SVGATextMode
/usr/sbin/SVGATextMode "80x34x9"
</screen>
</para>
<para>
Please note that the block cursor only works with some modes; on my
notebook, "80x30x9".
</para>
</sect2>
</sect1>
<!-- Common tasks -->
<sect1>
<title>Common Administration Tasks</title>
<para>
Here is where the fun begins. This section is rather network-centric,
though many other tasks await you.
</para>
<para>
Networking is a vast subject which cannot be fully covered here. The
reference is the NET-3 HOWTO, and most distributions provide documentation
on setting up network services. Only a few points will be recalled here.
</para>
<para>
A quick to-do list for the services you may want to install: cron and
timed tasks like calendar or reminder, Http, Samba, telnet/ssh access,
anonymous ftp, POP/IMAP server, NFS...
</para>
<!-- Network cfg -->
<sect2>
<title>Network Configuration</title>
<para>
If your network card wasn't recognised at install time, don't worry: in
most cases it's either NE2000 or 3c59x compatible. Issue the command
<filename>modprobe ne</filename> or <filename>modprobe 3c59x</filename>
and see if the relevant module is loaded, then add this line in
<filename>/etc/conf.modules</filename>:
</para>
<para>
<screen>
alias eth0 ne # or 3c59x
</screen>
</para>
<para>
Now you're ready to use <filename>netcfg</filename> or similar tool to set
up the network configuration. The relevant files are
<filename>/etc/HOSTNAME</filename>, <filename>etc/hosts</filename>,
<filename>/etc/resolv.conf</filename>,
<filename>/etc/sysconfig/network</filename>, and
<filename>/etc/sysconfig/network-scripts/ifcfg-eth0</filename>; services
should be started with scripts in <filename>/etc/rc.d/init.d</filename>.
</para>
<para>
This is a sample <filename>etc/hosts</filename>:
</para>
<para>
<screen>
127.0.0.1 localhost
192.168.1.1 paleo.eocene.net paleo
192.168.1.2 nautilus.eocene.net nautilus
</screen>
</para>
<para>
This is <filename>/etc/resolv.conf</filename>:
</para>
<para>
<screen>
search df.unibo.it,eocene.net
nameserver 195.210.91.100
</screen>
</para>
<para>
This is <filename>/etc/sysconfig/network</filename> (Red Hat-dependent):
</para>
<para>
<screen>
NETWORKING=false
FORWARD_IPV4=true
HOSTNAME=nautilus.eocene.net
DOMAINNAME=eocene.net
</screen>
</para>
<para>
And finally, <filename>/etc/sysconfig/network-scripts/ifcfg-eth0</filename>.
This one, too, is Red Hat-dependent; it must be executable.
</para>
<para>
<screen>
DEVICE=eth0
IPADDR=192.168.1.2
NETMASK=255.255.255.0
NETWORK=192.168.1.0
BROADCAST=192.168.1.255
ONBOOT=no
</screen>
</para>
<para>
Although the actual method of starting network services of your
distribution may be much more complex, the following script should be
enough to get you started:
</para>
<para>
<screen>
#!/bin/sh
# net-up.sh: set up network access
DEVICE=eth0
IPADDR=192.168.1.100
NETMASK=255.255.255.0
NETWORK=192.168.1.0
GATEWAY=192.168.1.1
ifconfig $DEVICE $IPADDR netmask $NETMASK up
route add -net $NETWORK netmask $NETMASK $DEVICE
route add default gw $GATEWAY
</screen>
If you'd like to do networking experiments with the loopback interface, all
you have to do is:
<screen Width="80">
ifconfig lo 127.0.0.1
route add -host 127.0.0.1 lo
</screen>
</para>
<para>
This script is handy for enabling network access when you use a rescue
disk. Obviously, this lets you only ping, ftp and telnet to the outside;
it won't start any daemon.
</para>
</sect2>
<!-- Notebooks -->
<sect2>
<title>Network for Notebooks</title>
<para>
When you plug the network PC card in, the script
<filename>/etc/pcmcia/network</filename> will be run. All it needs is a
properly set up
<filename>/etc/sysconfig/network-scripts/ifcfg-eth0</filename>.
</para>
<para>
Setting up the network can become a bit trickier, though. In fact, you
must provide the right settings for each network you connect to, as well
as settings for the notebook when it's not connected.
</para>
<para>
I rolled up a rough but functional solution. I use my notebook as a
stand-alone machine, connecting to the net via PPP; at home, IP address
192.168.1.2; and at university, IP 137.204.x.y. So, I created a set of
configuration files for each network; all these are kept in
<filename>/etc/mobnet</filename>. A script is then used to select the
working environment. For instance, this is
<filename>/etc/mobnet/home.cfg</filename>:
</para>
<para>
<screen>
# /etc/mobnet/home.conf
HOSTNAME=nautilus.eocene.net # complete hostname
DOMAINNAME=eocene.net # your domain
IPADDR=192.168.1.2
NETMASK=255.255.255.0
NETWORK=192.168.1.0
BROADCAST=192.168.1.255
GATEWAY=192.168.1.1
FORWARD_IPV4=true
NAMESERVER=195.210.91.100 # required
SEARCH=df.unibo.it,eocene.net # optional
SERVICES="inet httpd smb sshd"
</screen>
</para>
<para>
This is <filename>mnet</filename>, the script I use to choose the network
profile:
</para>
<para>
<screen>
#!/bin/sh
# mnet: script to set up the "mobile network" configuration.
# Last modified: 15 July 2000
# start or stop services
activate_services()
{
for service in $(echo $SERVICES) ; do
[ -x /etc/rc.d/init.d/$service ] &#38;&#38; /etc/rc.d/init.d/$service $1
done
}
# usage
if [ $# = 0 ] ; then
echo "Usage: mnet &#60;config name>"
echo "Example: mnet office"
exit 1
fi
# check if the configuration exists
if [ ! -e /etc/mobnet/$1.conf ]; then
echo "This configuration doesn't exist."
exit 1
fi
# read the configuration
. /etc/mobnet/$1.conf
# set up the host name
echo $HOSTNAME > /etc/HOSTNAME
/bin/hostname $HOSTNAME
# set up the name server(s)
cat &#60;&#60;EOF > /etc/resolv.conf
# /etc/resolv.conf
search $SEARCH
nameserver $NAMESERVER
EOF
# stop previous services, if any
if [ -f /etc/mobnet/services.prev ]; then
NEWSERVICES=$SERVICES
. /etc/mobnet/services.prev
activate_services stop
SERVICES=$NEWSERVICES
fi
if [ $1 != "none" ]; then
# set up the network parameters
cat &#60;&#60;EOF > /etc/sysconfig/network
NETWORKING=yes
FORWARD_IPV4=true
HOSTNAME=$HOSTNAME
DOMAINNAME=$DOMAINNAME
GATEWAY=$GATEWAY
GATEWAYDEV=eth0
EOF
cat &#60;&#60;EOF > /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
IPADDR=$IPADDR
NETMASK=$NETMASK
NETWORK=$NETWORK
BROADCAST=$BROADCAST
ONBOOT=no
EOF
/bin/chmod +x /etc/sysconfig/network-scripts/ifcfg-eth0
# copy the other config files
/bin/cp -f /etc/mobnet/hosts.$1 /etc/hosts
/bin/cp -f /etc/mobnet/smb.conf.$1 /etc/smb.conf
echo -n "Insert the network PC card and press &#60;enter> when done: "
read
# OK, now start services
activate_services start
echo "SERVICES=\"$SERVICES\"" > /etc/mobnet/services.prev
else # it's not "none"
cat &#60;&#60;EOF > /etc/sysconfig/network
NETWORKING=false
FORWARD_IPV4=false
HOSTNAME=$HOSTNAME
DOMAINNAME=$DOMAINNAME
EOF
/bin/rm -f /etc/sysconfig/network-scripts/ifcfg-eth0*
/sbin/ifconfig eth0 down
echo "SERVICES=$SERVICES" > /etc/mobnet/services.prev
echo "Now you may remove the PC card."
exit 0
fi
# end of mnet.
</screen>
</para>
<para>
As I said, it is rough and even not complete: other files may depend on
the network, like <filename>/etc/fstab</filename>,
<filename>/etc/exports</filename>, and <filename>/etc/printcap</filename>.
Think about network printers and NFS shares. Feel free to adapt this
bare-bone solution to your needs.
</para>
</sect2>
<!-- Sharing -->
<sect2>
<title>Sharing the Internet</title>
<para>
One of the most useful tasks for a Linux server. Currently, most stock
kernels come with IP firewalling, masquerading and forwarding enabled by
default; if in doubt, consult the IP-Masquerade mini-HOWTO to learn how to
enable them. Then install ipfwadm (kernels 2.0.x; <ulink
URL="http://www.xos.nl/linux/ipfwadm/"><citetitle>
http://www.xos.nl/linux/ipfwadm/</citetitle></ulink>) or ipchains (kernels
2.2.x; <ulink URL=
"http://www.adelaide.net.au/~rustcorp/ipfwchains/ipfwchains.html">
<citetitle>
http://www.adelaide.net.au/~rustcorp/ipfwchains/ipfwchains.html
</citetitle></ulink>). Remember to enable kernel modules for the services
you need, e.g. for ftp you'll add this line to
<filename>/etc/rc.d/rc.sysconfig</filename>:
</para>
<para>
<screen>
/sbin/modprobe ip_masq_ftp
</screen>
</para>
<para>
Other modules are usually found in
<filename>/lib/modules/KERNEL-VERSION/ipv4</filename>.
</para>
<para>
Enabling IP masquerading for other machines in your local network is very
simple. First, check the network initialisation scripts
(<filename>/etc/sysconfig/network</filename> should be the right place) to
see if they contain a line that reads
<filename>FORWARD_IPV4=true</filename>. It's used to set
<filename>/proc/sys/net/ipv4/ip_forward</filename> to 1 when the network
subsystem comes up.
</para>
<para>
Add these lines to <filename>/etc/rc.d/rc.sysinit</filename>:
</para>
<para>
<screen>
# default: packets cannot reach the outside
/sbin/ipfwadm -F -p deny
# allow all machines on the local network to reach the Internet
/sbin/ipfwadm -F -a m -S 192.168.1.0/24 -D 0.0.0.0/0
# alternatively, allow only these two machines
# /sbin/ipfwadm -F -a m -S 192.168.1.100/24 -D 0.0.0.0/0
# /sbin/ipfwadm -F -a m -S 192.168.1.101/24 -D 0.0.0.0/0
</screen>
</para>
<para>
If you use a kernel of the 2.2.x series, use
<filename>ipfwadm-wrapper</filename> instead of
<filename>ipfwadm</filename> to get started quickly. More information at
<ulink URL="http://ipmasq.cjb.net"><citetitle><citetitle>
http://ipmasq.cjb.net</citetitle></citetitle></ulink>.
</para>
<para>
Now you'll want something to let client machines dial the ISP; I use
Mserver (<ulink URL="http://cpwright.villagenet.com/mserver/"><citetitle>
http://cpwright.villagenet.com/mserver/</citetitle></ulink>). Edit
<filename>etc/mserver.conf</filename>; the only entries that you should
modify are ``checkhost'', ``shadow'', and ``cname''. Then define your
connection(s). Obviously, install a suitable client on the client
machines.
</para>
</sect2>
<!-- Restricting -->
<sect2 id="Restricting">
<title>Restricting Network Access </title>
<para>
Let's suppose you connect to the Internet via PPP. Once you're connected,
your machine may become vulnerable to attacks. Insert this in
<filename>/etc/hosts.allow</filename>:
</para>
<para>
<screen>
# only allow access to localhost
ALL: 127.
</screen>
</para>
<para>
and this in <filename>/etc/hosts.deny</filename>:
</para>
<para>
<screen>
# deny access to everyone
ALL: ALL
</screen>
</para>
<para>
If you belong to a network with direct Internet access, you had better
disable finger, telnet, and possibly other services for security reasons;
use <filename>ssh</filename> instead of telnet. The file to edit is
<filename>/etc/inet.conf</filename>. Alternatively, you can restrict network
access putting this in <filename>/etc/hosts.allow</filename>:
</para>
<para>
<screen>
in.telnetd: 192.168.1., .another.trusted.network
in.ftpd: 192.168.1., .another.trusted.network
</screen>
</para>
<para>
and this in <filename>/etc/hosts.deny</filename>:
</para>
<para>
<screen>
in.telnetd: ALL
in.ftpd: ALL
</screen>
</para>
</sect2>
<!-- NFS -->
<sect2>
<title>NFS Exports</title>
<para>
</para>
<para>
It is common to export home directories on the server; a problem arises if a
user's UID and GID are not consistent across different machines. If user
`guido' has UID/GID = 500 on <filename>server</filename> and UID/GID = 512
on <filename>client</filename>, a convenient configuration is this:
</para>
<para>
<screen>
# /etc/exports
/tmp my.client.machine(rw)
/home/guido my.client.machine(rw,all_squash,anonuid=512,anongid=512)
</screen>
</para>
</sect2>
<!-- Samba -->
<sect2>
<title>Samba</title>
<para>
Almost trivial, but there's always a little bit to do. If you want to
connect Windows 98/NT clients, did you remember to read the docs and, in
case, enable clear text passwords? The distribution includes .reg files for
Win9x/NT/2000; if your clients can't connect to the Linux server, load them
on every client.
</para>
<para>
Samba comes with a fairly complete sample
<filename>/etc/smb.conf</filename>, but strangely it lacks a section showing
how to (un)mount removable media. The clauses <filename>preexec</filename>
and <filename>postexec</filename> do the trick:
</para>
<para>
<screen>
[cdrom]
comment = CD-ROM
path = /mnt/cdrom
public = yes
read only = yes
; you might need to use "root preexec/postexec"
preexec = mount /mnt/cdrom
postexec = umount /mnt/cdrom
</screen>
</para>
<para>
Also: you know what Swat is, don't you? Enable it adding this line in your
<filename>/etc/inetd.conf</filename>:
</para>
<para>
<screen>
swat stream tcp nowait.400 root /usr/sbin/swat swat
</screen>
</para>
<para>
and this in <filename>/etc/services</filename>:
</para>
<para>
<screen>
swat 901/tcp
</screen>
</para>
<para>
Restart <filename>inetd</filename> with SIGHUP, and point your browser to
<filename>http://localhost:901</filename>.
</para>
</sect2>
</sect1>
<!-- Software cfg -->
<sect1 id="config">
<title>Software Configuration </title>
<para>
These are the the configuration files we are going to custimise:
<filename>/etc/profile</filename> <filename>/etc/bashrc</filename>
<filename>.bashrc</filename> <filename>.bashrc .bash_profile .bash_logout
.inputrc .less .lessrc .xinitrc </filename> <filename>.fvwmrc .fvwm2rc95
.Xmodmap .Xmodmap.num .Xdefaults .jedrc </filename> <filename>.abbrevs.sl
.joerc .emacs </filename>. Don't add users until you have completed your
system configuration; you'll put the dot files in
<filename>/etc/skel</filename>.
</para>
<!-- bash -->
<sect2>
<title>bash (1)</title>
<para>
Arguably, the most important piece of software after the kernel. To tailor
the behaviour of <filename>bash</filename>, these are the main files to edit:
</para>
<para>
<itemizedlist>
<listitem>
<para>
<filename>/etc/bashrc</filename> contains system wide aliases and
functions;
</para>
</listitem>
<listitem>
<para>
<filename>/etc/profile</filename> contains system wide environment stuff
and startup programs;
</para>
</listitem>
<listitem>
<para>
<filename>&dollar;HOME/.bashrc</filename> contains user aliases and functions;
</para>
</listitem>
<listitem>
<para>
<filename>&dollar;HOME/.bash_profile</filename> contains user environment
stuff and startup programs;
</para>
</listitem>
<listitem>
<para>
<filename>&dollar;HOME/.inputrc</filename> contains key bindings and other
bits.
</para>
</listitem>
</itemizedlist>
</para>
<para>
Examples of these files are shown below. First, the most important:
<filename>/etc/profile</filename>. It's used to configure a lot of features
in your Linux box, as you will see in the following sections. Please look
out for reverse quotes!
</para>
<para>
<programlisting>
# /etc/profile
# System wide environment and startup programs
# Functions and aliases go in /etc/bashrc
# This file sets up the following features and programs:
# path, prompts, a few environment variables, colour ls, less,
# rxvt, Backspace key behaviour, xterm title.
#
# Users can override these settings and/or add others in their
# $HOME/.bash_profile
# first: root or normal user? Set PATH and umask accordingly. Note that the
# PATH is normally set by login (1), but what if you access the machine
# via ssh?
if [ $(id -gn) = $(id -un) -a $(id -u) -gt 14 ]; then
umask 002 # normal user
PATH="/usr/local/bin:/bin:/usr/bin:."
else
umask 022 # root
PATH="/sbin:/bin:/usr/sbin:/usr/bin"
fi
# Now extend the PATH.
PATH="$PATH:/usr/X11R6/bin:$HOME/bin:." # !!! Beware of ./ !!!
# notify the user: login or non-login shell. If login, the prompt is
# blue; otherwise, magenta. Root's prompt is red.
# See the Colour-ls mini HOWTO for an explanation of the escape codes.
USER=$(whoami)
if [ $LOGNAME = $USER ] ; then
COLOUR=44 # blue
else
COLOUR=45 # magenta
fi
if [ $USER = 'root' ] ; then
COLOUR=41 # red
PATH="$PATH:/usr/local/bin" # my choice
fi
ESC="\033"
PROMPT='\h' # hostname
STYLE='m' # plain
# PROMPT='\u' # username
# STYLE=';1m' # bold
PS1="\[$ESC[$COLOUR;37$STYLE\]$PROMPT:\[$ESC[37;40$STYLE\]\w\\$ "
PS2="> "
# Ulimits: no core dumps, max file size 200 Mb.
ulimit -c 0 -f 200000
# a few variables
USER=$(id -un)
LOGNAME=$USER
MAIL="/var/spool/mail/$USER" # sendmail, postfix, smail
# MAIL="$HOME/Mailbox" # qmail
NNTPSERVER=news.myisp.it # put your own here
VISUAL=jed
EDITOR=jed
HOSTNAME=$(/bin/hostname)
HISTSIZE=1000
HISTFileSIZE=1000
export PATH PS1 PS2 USER LOGNAME MAIL NNTPSERVER
export VISUAL EDITOR HOSTNAME HISTSIZE HISTFileSIZE
# enable colour ls
eval $(dircolors /etc/DIR_COLORS -b)
export LS_OPTIONS='-s -F -T 0 --color=yes'
# customize less
LESS='-M-Q'
LESSEDIT="%E ?lt+%lt. %f"
LESSOPEN="| lesspipe.sh %s"
LESSCHARDEF=8bcccbcc13b.4b95.33b. # show colours in ls -l | less
# LESSCHARSET=latin1
PAGER=less
export LESS LESSEDIT LESSOPEN VISUAL LESSCHARDEF PAGER
# you might need this to fix the backspace key in rxvt/xterm
stty erase ^H # alternative: ^?
# set xterm title: full path
case $TERM in
xterm*|rxvt)
PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"'
;;
esac
for i in /etc/profile.d/*.sh ; do
if [ -x $i ]; then
. $i # beware - variables and aliases might get overridden!
fi
done
# call fortune, if available
if [ -x /usr/games/fortune ] ; then
echo ; /usr/games/fortune ; echo
fi
</programlisting>
</para>
<para>
This is a sample <filename>/etc/bashrc</filename>:
</para>
<para>
<programlisting>
# /etc/bashrc
# System wide functions and aliases
# Environment stuff goes in /etc/profile
# Insert PS1 definitions here if you experience problems.
export CDPATH="$CDPATH:~"
# common aliases
alias cp='cp -i'
alias l=less
alias ls="ls $LS_OPTIONS"
alias mv='mv -i'
alias rm='rm -i'
alias rmbk='/bin/rm -f .*~ *~ *aux *bak *log *tmp 2> /dev/null'
alias u='cd ..'
alias which="type -path"
alias x=startx
# A few useful functions
c () # cd to the new directory and list its contents
{
cd $1 ; ls
}
inst() # Install a .tar.gz archive in current directory
{
if [ $# != 0 ]; then tar zxvf $1; fi
}
cz() # List the contents of a .zip archive
{
if [ $# != 0 ]; then unzip -l $*; fi
}
ctgz() # List the contents of a .tar.gz archive
{
for file in $* ; do
tar ztf ${file}
done
}
tgz() # Create a .tgz archive a la zip.
{
if [ $# != 0 ]; then
name=$1.tar; shift; tar -rvf ${name} $* ; gzip -9 ${name}
fi
}
crpm() # list information on an .rpm file
{
if [ $# != 0 ]; then rpm -qil $1 | less; fi
}
</programlisting>
</para>
<para>
This is a sample <filename>.bashrc</filename>:
</para>
<para>
<programlisting>
# $HOME/.bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# this is needed to notify the user that they are in non-login shell
if [ "$GET_PS1" = "" ] ; then
COLOUR=45; ESC="\033"; STYLE=';1m'; # STYLE='m'
USER=$(whoami)
export PS1="\[$ESC[$COLOUR;37$STYLE\]$USER:\[$ESC[37;40$STYLE\]\w\\$ "
fi
# personal aliases
alias backup='tar -Mcvf /dev/fd0'
alias dial='eznet up myisp'
alias f='cd ~/fortran'
alias hangup='eznet down'
alias lyx='lyx -width 580 -height 450'
alias restore='tar -M -xpvf /dev/fd0'
# personal functions
xj() # Launch xjed and a file in background
{
xjed $1 &#38;
}
</programlisting>
</para>
<para>
This is a sample <filename>.bash_profile</filename>:
</para>
<para>
<programlisting>
# $HOME/.bash_profile
# User specific environment and startup programs
# This file contains user-defined settings that override
# those in /etc/profile
# Get user aliases and functions
if [ -f ~/.bashrc ]; then
GET_PS1="NO" # don't change the prompt colour
. ~/.bashrc
fi
# set a few `default' directories
export CDPATH="$CDPATH:$HOME:$HOME/text:$HOME/text/geology"
</programlisting>
</para>
<para>
This is a sample <filename>.inputrc</filename>:
</para>
<para>
<programlisting>
# $HOME/.inputrc
# key bindings
"\e[1~": beginning-of-line
"\e[3~": delete-char
"\e[4~": end-of-line
# (F1 .. F5) are "\e[[A" ... "\e[[E"
"\e[[A": "info \C-m"
set bell-style visible # please don't beep
set meta-flag On # allow 8-bit input (i.e, accented letters)
set convert-meta Off # don't strip 8-bit characters
set output-meta On # display 8-bit characters correctly
set horizontal-scroll-mode On # scroll long command lines
set show-all-if-ambiguous On # after TAB is pressed
</programlisting>
</para>
<para>
To make the backspace and delete keys work correctly in
<filename>xterm</filename> and other X11 applications, the following is also
needed:
</para>
<para>
<itemizedlist>
<listitem>
<para>
put this in your <filename>.xinitrc</filename>:
<screen>
usermodmap=$HOME/.Xmodmap
xmodmap $usermodmap
</screen>
</para>
</listitem>
<listitem>
<para>
then your <filename>.Xmodmap</filename> will contain:
<screen>
keycode 22 = BackSpace
keycode 107 = Delete
</screen>
this fixes the console. To fix <filename>xterm</filename>:
</para>
</listitem>
<listitem>
<para>
put this in your <filename>.Xdefaults</filename>:
<screen>
xterm*VT100.Translations: #override &#60;Key>BackSpace: string(0x7F)\n\
&#60;Key>Delete: string(0x1b) string("[3~")\n\
&#60;Key>Home: string(0x1b) string("[1~")\n\
&#60;Key>End: string(0x1b) string("[4~")\n\
Ctrl&#60;Key>Prior: string(0x1b) string("[40~")\n\
Ctrl&#60;Key>Next: string(0x1b) string("[41~")
nxterm*VT100.Translations: #override &#60;Key>BackSpace: string(0x7F)\n\
&#60;Key>Delete: string(0x1b) string("[3~")\n\
&#60;Key>Home: string(0x1b) string("[1~")\n\
&#60;Key>End: string(0x1b) string("[4~")\n\
Ctrl&#60;Key>Prior: string(0x1b) string("[40~")\n\
Ctrl&#60;Key>Next: string(0x1b) string("[41~")
</screen>
</para>
</listitem>
</itemizedlist>
</para>
<para>
<filename>rxvt</filename> is a wee bit more complicated, as some
compile--time options influence its behaviour. See the above
<filename>/etc/profile</filename>.
</para>
<para>
More info in <filename>bash</filename> (1) and
<filename>readline</filename> (3) man pages.
</para>
<para>
Don't expect every application to work correctly! If you run
<filename>joe</filename> in <filename>xterm</filename>, for instance, some
keys won't work; the same holds for some versions of
<filename>rxvt</filename>.
</para>
</sect2>
<!-- internationalisation -->
<sect2>
<title>I18n</title>
<para>
(This section doesn't apply to native English speakers.)
</para>
<para>
A.k.a. ``internationalisation''. Gasp. This long word means ``to adapt Linux
to your local conventions: language, format of date, currency etc.''.
</para>
<para>
Although Red Hat has its own method for setting up i18n
(<filename>/etc/sysconfig/i18n</filename>), you may want to enable your
language only in some cases. I, for one, enabled i18n in
<filename>kdm</filename> (via <filename>kdmconfig</filename>) and
<filename>xfce</filename>, but want to read English messages when I work in
console or xterm.
</para>
<para>
Consider these lines:
</para>
<para>
<screen>
LANG=it # choose your language: fr, de, es, ...
LANGUAGE=it
LC_ALL=it
export LANG LANGUAGE LC_ALL
</screen>
</para>
<para>
If you insert them in your <filename>.xinitrc</filename> or
<filename>.xsession</filename> just before the line that starts the window
manager, you'll get internationalised messages - including those in xterms
started from within the window manager. But if you'd rather get English
messages, set the language to ``en'' and put the same lines in
<filename>.bash_profile</filename>.
</para>
</sect2>
<!-- ls -->
<sect2>
<title>ls (1)</title>
<para>
<filename>ls</filename> can display directory listings using colours to
highlight different file types. To enable this feature, you just need a
couple of lines in <filename>/etc/profile</filename> as seen above. However,
this won't work with old versions of <filename>rxvt</filename>; use some
flavour of <filename>xterm</filename> instead. It looks like some old
<filename>rxvt</filename>s have a bug that prevents them from inheriting the
environment correctly in some circumstances.
</para>
</sect2>
<!-- less -->
<sect2>
<title>less (1)</title>
<para>
With this excellent pager you can browse not only plain text files, but also
gzip compressed, tar and zip archives, man pages, and what have you. Its
configuration involves a few steps:
</para>
<para>
<itemizedlist>
<listitem>
<para>
to use it with the movement keys, have this plain ASCII
file <filename>.lesskey</filename> in your home directory:
<screen>
^[[A back-line
^[[B forw-line
^[[C right-scroll
^[[D left-scroll
^[OA back-line
^[OB forw-line
^[OC right-scroll
^[OD left-scroll
^[[6~ forw-scroll
^[[5~ back-scroll
^[[1~ goto-line
^[[4~ goto-end
^[[7~ goto-line
^[[8~ goto-end
</screen>
then run the command <filename>lesskey</filename>. (These are escape
sequences for vt100-like terminals.) This creates a binary file
<filename>.less</filename> containing the key bindings.
</para>
</listitem>
<listitem>
<para>
write the following file as <filename>/usr/bin/lesspipe.sh</filename>:
<programlisting>
#!/bin/sh
# This is a preprocessor for 'less'. It is used when this environment
# variable is set: LESSOPEN="|lesspipe.sh %s"
lesspipe () {
case "$1" in
*.tar) tar tf $1 2>/dev/null ;; # View contents of .tar and .tgz files
*.tgz|*.tar.gz|*.tar.Z|*.tar.z) tar ztf $1 2>/dev/null ;;
*.Z|*.z|*.gz) gzip -dc $1 2>/dev/null ;; # View compressed files correctly
*.tar.bz2) bzip2 -dc $1 | tar tf - ;;
*.bz2) bzip2 -dc $1 2>/dev/null ;;
*.zip) unzip -l $1 2>/dev/null ;; # View archives
*.arj) unarj -l $1 2>/dev/null ;;
*.rpm) rpm -qpil $1 2>/dev/null ;;
*.cpio) cpio --list -F $1 2>/dev/null ;;
*.1|*.2|*.3|*.4|*.5|*.6|*.7|*.8|*.9|*.n|*.l|*.man)
file $1 | grep roff > /dev/null
if [ $? = 0 ]; then
groff -Tascii -mandoc $1
fi ;;
*) file $1 | grep "te[sx]t" > /dev/null ;
if [ $? = 1 ] ; then # it's not some kind of text
strings $1
fi ;;
esac
}
# treat link targets, not links themselves
file $1 | grep symbolic > /dev/null
if [ $? = 0 ]; then
TARGET=$(file $1 | awk '{print $NF}')
lesspipe $TARGET
else
lesspipe $1
fi
</programlisting>
then make it executable with <filename>chmod 755 lesspipe.sh</filename>.
</para>
</listitem>
<listitem>
<para>
put the variables that affect <filename>less</filename> in
<filename>/etc/profile</filename> as seen above.
</para>
</listitem>
</itemizedlist>
</para>
</sect2>
<!-- Editor -->
<sect2>
<title>Editor</title>
<para>
Only the most popular will be covered here.
</para>
<!-- Emacs -->
<sect3>
<title>emacs (1)</title>
<para>
I rarely use <filename>emacs</filename>, so I have only a couple of tips for
you. Some <filename>emacs</filename> distributions don't come preconfigured
for colours and syntax highlighting. Put this in your
<filename>.emacs</filename>:
</para>
<para>
<screen>
(global-font-lock-mode t)
(setq font-lock-maximum-decoration t)
</screen>
</para>
<para>
This only works in X11. Moreover, to enable accented characters you'll add
this line:
</para>
<para>
<screen>
(standard-display-european 1)
</screen>
</para>
<para>
I'll leave it to you to peruse all of <filename>emacs</filename>'
documentation to find out how to tailor it to your needs---potentially, it
can take months of hacking. The Dotfile generator (Section <XRef
LinkEnd="Config-sw">) is a good helping hand.
</para>
</sect3>
<!-- joe -->
<sect3>
<title>joe (1)</title>
<para>
(Why use <filename>joe</filename> when <filename>jed</filename> is so
small and powerful? Duh.)
</para>
<para>
Some versions of <filename>joe</filename> don't work with colours in
console, and some special keys don't work either. A quick and dirty (and
inelegant) solution to the former problem is this:
</para>
<para>
<screen>
~$ export TERM=vt100
~$ joe myfile
(edit your file)
~$ export TERM=linux
</screen>
</para>
<para>
To make the special keys work, all you have to do is edit
<filename>.joerc</filename>, <filename>.jstarrc</filename> or your favourite
emulation; you can start from the system-wide config files in
<filename>/usr/lib/joe</filename>. Look for the fourth section (key
bindings). This enables Home and End:
</para>
<para>
<screen>
bol ^[ [ 1 ~ Go to beginning of line
eol ^[ [ 4 ~ Go to end of line
</screen>
</para>
<para>
Find out the desired ESC sequences typing <filename>cat</filename> followed
by the special keys.
</para>
</sect3>
<!-- jed -->
<sect3 id="jed">
<title>jed (1) </title>
<para>
This is my favourite editor: it does what I need, it's lighter and easier to
configure than <filename>emacs</filename>, and emulates other editors quite
well. Many users at my university use <filename>jed</filename> to emulate
<filename>EDT</filename>, VMS' system editor.
</para>
<para>
<filename>jed</filename>'s configuration files are
<filename>.jedrc</filename> and <filename>/usr/lib/jed/lib/*</filename>; the
former can be adapted from <filename>jed.rc</filename> in the latter
directory.
</para>
<para>
<itemizedlist>
<listitem>
<para>
if <filename>xjed</filename> apparently doesn't recognise the DEL key, add
or comment out these lines in your <filename>.jedrc</filename>:
<screen>
#ifdef XWINDOWS
x_set_keysym (0xFFFF, 0, "\e[3~");
setkey (``delete_char_cmd'', "\e[3~");
#endif
</screen>
</para>
</listitem>
<listitem>
<para>
to make <filename>jed</filename> emulate <filename>EDT</filename> (or other
editors) all you have to do is edit a couple of lines in
<filename>.jedrc</filename>. If you want the numeric keypad
`<filename>+</filename>' to delete words instead of a single character, add
this in <filename>.jedrc</filename>:
<screen>
unsetkey("\eOl");
unsetkey("\eOP\eOl");
setkey("edt_wdel", "\eOl");
setkey("edt_uwdel", "\eOP\eOl");
</screen>
after the line that reads <filename>() = evalfile("edt")</filename> (or
similar);
</para>
</listitem>
<listitem>
<para>
to make <filename>xjed</filename> use the numeric keypad for
<filename>EDT</filename> emulation, insert the following in
<filename>.Xmodmap</filename>:
<screen>
keycode 77 = KP_F1
keycode 112 = KP_F2
keycode 63 = KP_F3
keycode 82 = KP_F4
keycode 86 = KP_Separator
</screen>
</para>
</listitem>
<listitem>
<para>
colour customization for <filename>xjed</filename> is done adding lines
like these in <filename>.Xdefaults</filename>:
<screen>
xjed*Geometry: 80x32+150+50
xjed*font: 10x20
xjed*background: midnight blue
# and so on...
</screen>
</para>
</listitem>
<listitem>
<para>
the ``abbreviation'' feature is an invaluable timesaver. Write a file like
the following as <filename>&dollar;HOME/.abbrevs.sl</filename> (you can
change this name by inserting <filename>variable Abbrev_File =
"/usr/lib/jed/abbrev.sl";</filename> in <filename>.jedrc</filename>):
<screen>
create_abbrev_table ("Global", "0-9A-Za-z");
define_abbrev ("Global", "GG", "Guido Gonzato");
create_abbrev_table ("TeX", "\\A-Za-z0-9");
define_abbrev ("TeX", "\\beq", "\\begin{equation}");
define_abbrev ("TeX", "\\eeq", "\\end{equation}");
% and so on...
</screen>
and type <filename>ESC x abbrev_mode</filename> to enable it. To enable the
abbreviation by default, add entries like these to your
<filename>.jedrc</filename>:
<screen>
define text_mode_hook ()
{
set_abbrev_mode (1);
}
%
define fortran_hook ()
{
set_abbrev_mode (1);
use_abbrev_table ("Fortran");
}
% and so on...
</screen>
</para>
</listitem>
</itemizedlist>
</para>
</sect3>
</sect2>
<!-- pine -->
<sect2>
<title>pine (1)</title>
<para>
Edit the global configuration in <filename>/usr/lib/pine.conf</filename>,
taking care at least of the following fields:
<filename>user-domain</filename>, <filename>smtp-server</filename>, and
<filename>nntp-server</filename>. Note that <filename>inbox-path</filename>
depends on your MTA: if you use <filename>sendmail</filename> or
<filename>postfix</filename>, that'll be
<filename>var/spool/mail/$USER</filename>; with Qmail,
<filename>/home/$USER/Mailbox</filename> (but root will use
<filename>/var/qmail/alias/Mailbox</filename>.
</para>
</sect2>
<!-- minicom -->
<sect2>
<title>minicom (1)</title>
<para>
Users can't use <filename>minicom</filename> unless a global configuration
has been made by root. Remember to make it.
</para>
</sect2>
<!-- efax -->
<sect2>
<title>efax (1)</title>
<para>
This package is probably the most convenient for simple sending/receiving of
faxes. You'll have to tailor the script <filename>/usr/bin/fax</filename> or
(mandrake) <filename>/etc/fax.config</filename>; easy job, but a couple of
quirks caused me quite a headache:
</para>
<para>
<itemizedlist>
<listitem>
<para>
to find out whether your modem is class 1, 2, or 2.0, use minicom or
similar program to issue the command <filename>at+fclass=?</filename>. The
reply may be like <filename>0,1,2</filename>; 1 and 2 are the classes
supported by your modem;
</para>
</listitem>
<listitem>
<para>
DIALPREFIX: chances are that simply putting `<filename>T</filename>' or
`<filename>P</filename>' won't work in some countries-in Italy, at least. Put
`<filename>ATDT</filename>' or `<filename>ATDP</filename>' instead;
</para>
</listitem>
<listitem>
<para>
INIT and RESET: these strings contain the initialisers
`<filename>-i</filename>' and `<filename>-k</filename>', needed by
<filename>efax</filename>. If you want to add an AT command, add it to the
appropriate string leaving out `<filename>AT</filename>' and preceding the
rest with either `<filename>-i</filename>' or `<filename>-k</filename>'.
Example: to add the `<filename>ATX3</filename>' command to INIT, you'll
append `<filename>-iX3</filename>'.
</para>
</listitem>
</itemizedlist>
</para>
<para>
That done, there are a few permissions to fix to enable non-root users to
send and receive faxes. The directories <filename>/var/lock</filename> and
<filename>/var/spool/fax</filename> must be writable. To do so, create the
group <filename>faxusers</filename>, add users to it, then type:
</para>
<para>
<screen>
~# chown root.faxusers /var/lock
~# mkdir /var/spool/fax # if it doesn't exist yet
~# chown root.faxusers /var/spool/fax; chmod g+w /var/spool/fax
</screen>
</para>
<para>
As a normal user, you'll issue <filename>newgrp faxusers</filename> before
sendig a fax.
</para>
</sect2>
<!-- Ghostscript -->
<sect2>
<title>Ghostscript</title>
<para>
This essential tool suffers from a small snag. Owing to to the well-known
export regulations in the USA, the utility <filename>pdf2ps</filename>
doesn't work with encrypted .pdf files. Never mind: point your browser to
<ulink URL="http://www.ozemail.com.au/~geoffk/pdfencrypt"><citetitle>
http://www.ozemail.com.au/~geoffk/pdfencrypt</citetitle></ulink>, download
the file <filename>pdf_sec.ps</filename> and replace the file with the same
name that comes with the Ghostscript distribution.
</para>
</sect2>
<!-- TeX -->
<sect2>
<title>TeX and Friends</title>
<para>
The ``root'' of a TeX system is the directory &dollar;TEXMF, which is
<filename>/usr/share/texmf</filename> in teTeX; other distributions may
differ (search for ``texmf'' on your system). You normally add stuff or
fiddle with files therein.
</para>
<!-- TEXINPUTS -->
<sect3>
<title>Expanding &dollar;TEXINPUTS</title>
<para>
To include PostScript figures or TeX files that reside in subdirectories, it
is convenient to expand TeX's search path to include subdirectories. Put
this command in your <filename>.bash_profile</filename>:
</para>
<para>
<screen>
export TEXINPUTS="$HOME/mylib::./figures"
</screen>
</para>
<para>
which makes TeX search in <filename>$HOME/mylib</filename>
<emphasis>before</emphasis> the default directories, and the directory
<filename>./figures</filename> <emphasis>afterwards</emphasis>.
</para>
</sect3>
<!-- Hyphen -->
<sect3>
<title>Hyphen Patterns</title>
<para>
To configure the hyphenation pattern for your language, edit the file
<filename>&dollar;TEXMF/tex/generic/config/language.dat</filename>, then do:
</para>
<para>
<screen>
~# texconfig init ; texconfig hyphen
</screen>
</para>
<para>
Even if you don't write in English, don't remove the entry ``english''; TeX
pukes without it.
</para>
</sect3>
<!-- dvips -->
<sect3>
<title>dvips (1)</title>
<para>
To tailor <filename>dvips</filename>, the file to edit is
<filename>&dollar;TEXMF/dvips/config/config.ps</filename>. Be aware that the
fields regarding the default resolution also affect
<filename>xdvi</filename>'s behaviour; if you experience annoying attempts
to create fonts each time you run it, put the line
</para>
<para>
<screen>
XDvi*mfmode:
</screen>
</para>
<para>
in your <filename>.Xdefault</filename>. This should help.
</para>
</sect3>
<!-- adding packages -->
<sect3>
<title>Adding LaTeX Packages</title>
<para>
Additional LaTeX packages are available from your nearest CTAN
(Comprehensive TeX Archive Network) mirror site, e.g. <ulink
URL="ftp://ftp.dante.de/pub/tex"><citetitle>
ftp://ftp.dante.de/pub/tex</citetitle></ulink>. Unpack the package under
<filename>&dollar;TEXMF/tex/latex</filename>.
</para>
<para>
If no .sty file exist, run the command <filename>latex
newstyle.ins</filename> or <filename>latex newstyle.dtx</filename> to create
it, then run the command <filename>texhash</filename> so that teTeX
recognises the new package.
</para>
</sect3>
</sect2>
<!-- docbook -->
<sect2 id="docbook">
<title>Docbook</title>
<para>
LaTeX is the best choice for typesetting, Docbook for multiformat
documents (This HOWTO is written in Docbook.) Once you get all of the
tools in place, you'll want to use simple scripts to avoid the complex
command line. If these are not provided with the distribution, use the
following <filename>db2pdf</filename> as template:
</para>
<programlisting>
#!/bin/sh
if [ $# = 0 ]; then
echo "Usage: db2pdf &lt;file.sgml&gt; [file2.sgml ...]"
exit 1
fi
# Standard Mandrake location:
DSSSL=/usr/share/sgml/docbook/dsssl-stylesheets-1.57/print/docbook.dsl
# Standard RedHat location:
# /usr/lib/sgml/stylesheets/nwalsh-modular/print/docbook.dsl
if [ ! -f $DSSSL ]; then
DSSSL=$(find /usr/ -name "docbook.dsl" | grep print)
fi
for FILE in $*
do
NAME=$(echo $FILE | awk -F'.' '{print $1}')
echo "Processing $FILE..."
jade -t tex -d $DSSSL $NAME.sgml
pdfjadetex $NAME.tex
done
# End of db2pdf
</programlisting>
<para>
If you find that your PostScript od .PDF looks very bad, the file to hack
is <filename>dbparams.dsl</filename>. In my Mandrake system, it's located
in <filename id="directory">
/usr/share/sgml/docbook/dsssl-stylesheets-1.57/print/</filename>.
</para>
</sect2>
<!-- PPProblems -->
<sect2>
<title>Avoid PPProblems!</title>
<para>
I'll take it for granted that your kernel has PPP + TCP/IP support compiled
in, that loopback is enabled, and that you already have the
<filename>pppd</filename> package correctly installed and, if you will, set
uid root. Obviously, your ISP must support PPP.
</para>
<para>
There are now two ways to get PPP to work: a) manual configuration, and b) a
configuration program that automagically sees to it. Whichever option you
choose, have the following information on hand:
</para>
<para>
<itemizedlist>
<listitem>
<para>
your ISP's telephone number;
</para>
</listitem>
<listitem>
<para>
your ISP's name, mail and news server address;
</para>
</listitem>
<listitem>
<para>
your ISP's domain;
</para>
</listitem>
<listitem>
<para>
your username and password.
</para>
</listitem>
</itemizedlist>
</para>
<para>
Manual configuration is a drudgery. It's about editing files and writing
scripts; not too much work, but it's easy to make mistakes and newcomers are
often intimidated. The PPP HOWTO is there for you. Alternatively, there are
tools that ask for the information above and do all the work.
</para>
<para>
Gnome and KDE include, respectively, <filename>gnome-ppp</filename> and
<filename>kppp</filename> which are easy enough to set up. Alternatively, I
suggest that you have a look at a couple of tty--based tools,
<filename>wvdial</filename> and <filename>eznet</filename>. You feed them
your ISP's phone number, your username, your password, and you're in
business. Their home pages are at <ulink
URL="http://www.worldvisions.ca/wvdial"><citetitle>
http://www.worldvisions.ca/wvdial</citetitle></ulink> and <ulink
URL="http://www.hwaci.com/sw/eznet"><citetitle>
http://www.hwaci.com/sw/eznet</citetitle></ulink>. Both are great, but I
prefer the latter.
</para>
<!-- eznet -->
<sect3>
<title>A Quick Start with eznet</title>
<para>
First of all, create an <filename>/etc/resolv.conf</filename> like this:
</para>
<para>
<screen>
nameserver w.x.y.z
</screen>
</para>
<para>
where you'll insert the address of your ISP's nameserver. To create an
account with <filename>eznet</filename>, issue the following command:
</para>
<para>
<screen>
#~ eznet add service=YOUR_ISP user=NAME password=PASSWORD phone=PHONE
</screen>
</para>
<para>
which creates the file <filename>/var/eznet/eznet.conf</filename>, owned by
root.root with permissions 600; chmod it to 666 if you want it to be world
readable. Now dial your ISP with <filename>eznet up YOUR_ISP</filename>. If
the modem keeps waiting for the dial tone and won't connect, then try this
command:
</para>
<para>
<screen>
#~ eznet change YOUR_ISP init0=atx3
</screen>
</para>
<para>
To hang up, the command is <filename>eznet down</filename>. That's all!
</para>
</sect3>
<!-- wvdial -->
<sect3>
<title>A Quick Start with wvdial</title>
<para>
<filename>wvdial</filename>'s setup is even shorter. Type
<filename>wvdialconf /etc/wvdial.conf</filename>, then edit the resulting
file to include your username, password, and phone number. Try it out with
<filename>wvdial</filename>, and keep your fingers crossed. To hang up, stop
it with Ctrl-C.
</para>
</sect3>
</sect2>
<!-- POP client -->
<sect2>
<title>POP Client</title>
<para>
To retrieve your mail from a POP3 server, you need a POP client. Most such
clients require that you run an MTA like <filename>sendmail</filename>,
<filename>qmail</filename> or <filename>postfix</filename>; a bit of an
overkill on low-spec machines. However, there are clients that work without
an MTA. The first kind is well represented by
<filename>fetchmail</filename>; the second by <filename>fetchpop</filename>
or <filename>frenchie</filename>. Sites: <ulink
URL="ftp://metalab.unc.edu/pub/Linux/system/mail/pop"><citetitle>
ftp://metalab.unc.edu/pub/Linux/system/mail/pop</citetitle></ulink>, <ulink
URL="http://www.lowcountry.com/~jscottb/tcltk.shtml"><citetitle>
http://www.lowcountry.com/~jscottb/tcltk.shtml</citetitle></ulink>.
</para>
<para>
To configure these clients:
</para>
<para>
<itemizedlist>
<listitem>
<para>
<filename>fetchpop</filename>: the first time you run it, you'll be
prompted for some information. Answer the questions and you're set.
<filename>fetchpop</filename> must be used with the <filename>-r</filename>
switch if your ISP's POP3 server doesn't implement the command LAST
properly.
</para>
</listitem>
<listitem>
<para>
<filename>frenchie</filename>: as above, edit
<filename>&nbsp;/.frenchie/frenchierc</filename>;
</para>
</listitem>
<listitem>
<para>
<filename>fetchmail</filename>: adapt this sample
<filename>.fetchmailrc</filename>:
<screen>
# $HOME/.fetchmailrc
poll mbox.myisp.com with protocol pop3;
user john there with password _Loo%ny is john here
</screen>
One user reported that adding ``smtphost localhost'' to the second line
improved performance dramatically.
You must set the permissions to this file with the command <filename>chmod
600 .fetchmailrc</filename>, otherwise <filename>fetchmail</filename> will
rightly refuse to start. This example is very basic; there are endless
possibilities of configuration. Check out at <ulink
URL="http://www.ccil.org/~esr/fetchmail"><citetitle>
http://www.ccil.org/~esr/fetchmail</citetitle></ulink>.
</para>
</listitem>
</itemizedlist>
</para>
</sect2>
<!-- mail filtering -->
<sect2>
<title>Basic Mail Filtering</title>
<para>
You will want to protect yourself from spam or huge mail messages. There are
two cases: 1) permanent connection to the net, 2) a POP link. In the first
case, you can write a <filename>.procmailrc</filename> file, while in the
second there are tools for checking the mail prior to fetching it.
</para>
<para>
A very simple <filename>.procmailrc</filename> that defines a few rules:
</para>
<para>
<screen>
# $HOME/.procmailrc
MAILDIR=$HOME/mail # make sure it exists
# Store messages directed to the "foo" mailing list to $HOME/mail/foo
:0
* ^To:.*foo
foo
# Discard messages that are not explicitly sent to me or to one of the
# mailling lists I subscribed to.
:0
* !^TO(guido|jed|lugvr|ldp|nobody)
/dev/null
# ditto, for messages larger than 50k.
:0
* > 50000
/dev/null
</screen>
</para>
<para>
<filename>man procmailex</filename> for further examples.
</para>
<para>
POP users will want to use <filename>poppy</filename>, a useful Perl script
for checking the mail before fetching it. Get it from <ulink
URL="ftp://metalab.unc.edu/system/mail/pop"><citetitle>
ftp://metalab.unc.edu/system/mail/pop</citetitle></ulink>.
</para>
</sect2>
<!-- XFree86 -->
<sect2>
<title>X Window System (XFree86)</title>
<!-- setup -->
<sect3>
<title>Setting Up the X Server</title>
<para>
Come on, it's no longer as difficult as it used to be... All major
distributions include a tool for setting up X11 (e.g.
<filename>XConfigurator</filename>, <filename>sax</filename>,
<filename>XF86Setup</filename>, or at least
<filename>xf86config</filename>). X configuration is virtually automatic
these days, but a few video cards may cause a headache.
</para>
<para>
First of all, check out at the XFree86 site (<ulink
URL="http://www.xfree86.org"><citetitle>
ftp://metalab.unc.edu/system/mail/pop</citetitle></ulink>) whether your
video card is supported. If so, then try this procedure:
</para>
<para>
<itemizedlist>
<listitem>
<para>
install the plain VGA server;
</para>
</listitem>
<listitem>
<para>
go to <ulink
URL="ftp://ftp.XFree86.org/pub/XFree86/current/binaries"><citetitle>
ftp://ftp.XFree86.org/pub/XFree86/current/binaries</citetitle></ulink>, cd
to the proper Linux subdirectory, and download the archives
<filename>X_version_bin.tgz</filename>,
<filename>X_version_set.tgz</filename>, and all the servers. Amongst other
programs, the first archive contains the most up-to-date
<filename>SuperProbe</filename>;
</para>
</listitem>
<listitem>
<para>
unpack <filename>X_version_bin.tgz</filename> to a temporary directory, cd
to it, and run <filename>./SuperProbe</filename>. If your video card is
recognised, chances are that you'll be able to set it up. Otherwise, hard
luck;
</para>
</listitem>
<listitem>
<para>
install the servers and <filename>X_version_set.tgz</filename> from
<filename>/usr/X11R6/</filename>, then run <filename>XF86Setup</filename>.
</para>
</listitem>
</itemizedlist>
</para>
<para>
This has always worked for me, but your mileage may vary. Please note that
most times X11 won't start because you chose wrong specs for your monitor!
Start with conservative settings, i.e. 800x600 and 256 colours, then pump
it up. <emphasis>Warning</emphasis>: these operations are dangerous and
your monitor might be damaged!
</para>
<para>
If your card isn't supported, you can either: 1) wait for the next version
of XFree86; 2) buy a commercial X server; 3) buy a supported video card.
<emphasis>Quartum non datur.</emphasis>
</para>
</sect3>
<!-- startup -->
<sect3>
<title>The X Startup Sequence</title>
<para>
There are two ways to launch X11: from the console via
<Command>startx</Command>, or directly via
<filename>/etc/inittab</filename>.
</para>
</sect3>
<!-- keypad -->
<sect3>
<title>Keypad</title>
<para>
We have seen above how to make a few special keys work. The sample file
<filename>.Xmodmap</filename> works well if you want to use Xjed, but it
makes the keypad unusable. You'll then need another config file, which
we'll call <filename>.Xmodmap.num</filename>:
</para>
<para>
<screen>
! Definitions can be found in &#60;X11/keysymdef.h
keycode 77 = Num_Lock
keycode 112 = KP_Divide
keycode 63 = KP_Multiply
keycode 82 = KP_Subtract
keycode 86 = KP_Add
keycode 79 = KP_7
keycode 80 = KP_8
keycode 81 = KP_9
keycode 83 = KP_4
keycode 84 = KP_5
keycode 85 = KP_6
keycode 87 = KP_1
keycode 88 = KP_2
keycode 89 = KP_3
keycode 90 = KP_0
keycode 91 = KP_Decimal
</screen>
</para>
<para>
Make sure that your <filename>/etc/X11/XF86Config</filename> does not
contain these three lines:
</para>
<para>
<screen>
ServerNumLock
Xleds
XkbDisable
</screen>
</para>
<para>
and in case, comment them out. To re-enable the keypad, you'll issue the
command <filename>xmodmap .Xmodmap.num</filename>.
</para>
</sect3>
<!-- xdm -->
<sect3>
<title>Graphical Login with xdm</title>
<para>
To be greeted by a graphical login, edit the file
<filename>/etc/inittab</filename>, which should include a line like this:
</para>
<para>
<screen>
x:5:respawn:/usr/bin/X11/xdm -nodaemon # also kdm or gdm
</screen>
</para>
<para>
where 5 is the runlevel corresponding to X11. Modify the line that defines
the default runlevel (usually 2 or 3), changing it as above:
</para>
<para>
<screen>
id:5:initdefault:
</screen>
</para>
<para>
The number of colours is specified in
<filename>/etc/X11/xdm/Xserver</filename>:
</para>
<para>
<screen>
:0 local /usr/X11R6/bin/X :0 -bpp 16 vt07 # first X server, 65k colours
:1 local /usr/X11R6/bin/X :1 -bpp 32 vt08 # second X server, true colour
</screen>
</para>
<para>
If you already have <filename>.xinitrc</filename>, copy it to
<filename>.xsession</filename> and make the latter executable with
<filename>chmod +x .xsession</filename>. Now issue the command
<filename>telinit 5</filename> and you're in business.
</para>
</sect3>
<!-- window manager -->
<sect3>
<title>Window Manager</title>
<para>
Once X works, there are endless possibilities of configuration; it depends
on the window manager you use, there are tens to choose from. Mostly, it's
all down to editing one or more ASCII files in your home directory; in
other cases you don't have to edit a thing, and use an applet or even a
menu.
</para>
<para>
Some examples:
</para>
<para>
<itemizedlist>
<listitem>
<para>
<emphasis remap="bf">the fvwm family</emphasis>: copy
<filename>/etc/X11/fvwm/system.fvwmrc</filename> (or similar) to your home
using the appropriate name, browse it and start experimenting. You may
waste a lot of time before you get the precise look and feel you like;
</para>
</listitem>
<listitem>
<para>
<emphasis remap="bf">WindowMaker</emphasis>: it has several config files
that live under <filename>$HOME/GNUstep</filename>, and a cool
configuration applet;
</para>
</listitem>
<listitem>
<para>
<emphasis remap="bf">KDE</emphasis>, <emphasis remap="bf">Gnome</emphasis>,
<emphasis remap="bf">xfce</emphasis> and others: nothing to edit manually
here, everything can be done via the menu.
</para>
</listitem>
</itemizedlist>
</para>
<para>
In short: if you don't mind editing config file, choose something like
<filename>icewm</filename>, <filename>fvwm*</filename>,
<filename>blackbox</filename> etc; if you do mind, the choice is currently
restricted to KDE, Gnome, WindowMaker, and Xfce. Email me if I'm wrong.
</para>
<para>
It's important to have a good <filename>.xinitrc</filename>. An example:
</para>
<para>
<screen>
#!/bin/sh
# $HOME/.xinitrc
usermodmap=$HOME/.Xmodmap
xmodmap $usermodmap
xset s noblank # turn off the screen saver
xset s 300 2 # screen saver start after 5 min
xset m 10 5 # set mouse acceleration
rxvt -cr green -ls -bg black -fg white -fn 7x14 \
-geometry 80x30+57+0 &#38;
if [ "$1" = "" ] ; then # default
WINMGR=wmaker
else
WINMGR=$1
fi
$WINMGR
</screen>
</para>
<para>
Although it doesn't appear to be strictly required, make it executable
with <filename>chmod +x .xinitrc</filename>.
</para>
<para>
The <filename>.xinitrc</filename> above lets you choose the window
manager: try
<screen>
$ startx startkde # or other w.m.
</screen>
</para>
</sect3>
<!-- defaults for X11 apps -->
<sect3>
<title>Defaults for X11 Apps</title>
<para>
Find out where the <filename>app-defaults</filename> directory is (it
should be <filename>/usr/X11R6/lib/X11/app-defaults</filename>). Several
apps keep a configuration file there.
</para>
</sect3>
<!-- adding fonts -->
<sect3>
<title>Adding Fonts</title>
<para>
Recent versions of XFree86 (say, &gt; 3.3.4) use an X Font Server that
supports PostScript Type 1 and True Type fonts natively, so you can use
the wealth of fonts available on the net. There's a simple procedure to
follow.
</para>
<para>
Suppose that you downloaded a Type 1 font collection, e.g. Freefont
(<ulink URL="ftp://ftp.gimp.org/pub/gimp/fonts/freefonts-0.10.tar.gz">
<citetitle>ftp://ftp.gimp.org/pub/gimp/fonts/freefonts-0.10.tar.gz
</citetitle></ulink>). To make it visible to the font server, unpack the
archive from <filename>/usr/X11R6/lib/X11/fonts/</filename>. Then edit
<filename>/etc/X11/fs/config</filename>, add an entry for the new
directory, and restart the font server.
</para>
<para>
If you're rolling your own font collection, you'll need to supply the
files <filename>fonts.dir</filename> and <filename>fonts.scale</filename>;
the tool to make them is <filename>type1inst</filename>, available from
<ulink
URL="http://http://goblet.anu.edu.au/~m9305357/type1inst.html"><citetitle>
http://http://goblet.anu.edu.au/~m9305357/type1inst.html
</citetitle></ulink>.
</para>
<para>
As for the True Type fonts, group them in a directory of your choice and
create <filename>fonts.dir</filename> using
<filename>ttmkfdirfonts.dir</filename>, included in the Freetype archive;
<ulink URL="http://www.freetype.org"><citetitle>http://www.freetype.org
</citetitle></ulink>. Then proceed as above. For example, if you want to
use the Windows fonts you have in, say,
<filename>/mnt/win/windows/fonts</filename>, go to that directory, run
<filename>ttmkfdir</filename>, edit
<filename>/etc/X11/fs/config</filename> and restart the font server.
</para>
<para>
It all started from the original True Type X font server: <ulink
URL="http://http://www.dcs.ed.ac.uk/home/jec/programs/xfsft/">
<citetitle>http://http://www.dcs.ed.ac.uk/home/jec/programs/xfsft/
</citetitle></ulink>.
</para>
</sect3>
</sect2>
<!-- users' configurations -->
<sect2>
<title>Users' Configurations</title>
<para>
When you're done editing the dot files, copy them to
<filename>/etc/skel</filename> as seen in Section <XRef LinkEnd="config">.
</para>
</sect2>
<!-- rpms -->
<sect2>
<title>Making .rpms</title>
<para>
<filename>rpm</filename> is such a wonderful method of keeping packages
under control that I'm reluctant to install .tar.gz archives but in very
few special cases (e.g., security). Whenever you install a tarball,
consider turning it into an .rpm archive, then reinstall it; consult the
RPM HOWTO. Also, if you use recent <filename>gcc</filename> versions, it
may be advisable to put this in your <filename>/etc/rpmrc</filename>:
</para>
<para>
<screen>
optflags: i386 -O2 -mpentiumpro
</screen>
</para>
</sect2>
<!-- Upgrading -->
<sect2>
<title>Upgrading</title>
<para>
If you upgrade your machine, do your backup as usual and remember to save
a few additional files. Some could be
<filename>/etc/X11/XF86Config</filename>,
<filename>/usr/bin/fax</filename>, all the stuff in
<filename>/usr/local</filename>, the kernel configuration, the whole
<filename>/etc</filename>, and all the mail in
<filename>/var/spool/mail</filename>.
</para>
<para>
Then it's time to upgrade (in rare cases, downgrade!) applications that
your distribution ship with, and to add additional packages. Keep a list
of these ones.
</para>
</sect2>
</sect1>
<!-- cfg software -->
<sect1 id="Config-sw">
<title>Configuration Software + Docs </title>
<para>
There are several programs that make Linux easy to setup and configure.
Some are becoming sort of standard: Red Hat, Caldera and other
distributions ship with apps like <filename>setup</filename>,
<filename>printtool</filename>, <filename>netcfg</filename>,
<filename>usertool</filename>, etc, while S.u.S.E. ships with a
comprehensive configuration program called Yast. Other useful programs
are:
</para>
<para>
<itemizedlist>
<listitem>
<para>
<emphasis remap="bf">The Dotfile Generator</emphasis>: fine X app with
modules to configure packages like <filename>emacs</filename>,
<filename>bash</filename>, <filename>procmail</filename> and more. Its
page is at <ulink
URL="http://www.imada.ou.dk/~blackie/dotfile"><citetitle>
http://www.imada.ou.dk/~blackie/dotfile</citetitle></ulink>;
</para>
</listitem>
<listitem>
<para>
<emphasis remap="bf">Linuxconf</emphasis>: the ultimate configuration
tool. It can do everything, both in console and under X. Go to <ulink
URL="http://www.solucorp.qc.ca/linuxconf"><citetitle>
http://www.solucorp.qc.ca/linuxconf</citetitle></ulink> at once.
</para>
</listitem>
</itemizedlist>
</para>
<para>
Documents on Linux configuration are popping up everywhere. One of the
most complete is TrinityOS, <ulink
URL="http://www.ecst.csuchico.edu/~dranch/LINUX/index-linux.html">
<citetitle> http://www.ecst.csuchico.edu/~dranch/LINUX/index-linux.html
</citetitle></ulink>. Bug the author to have him turn the document in
nicer formats.
</para>
<para>
A jolly good page is <ulink URL="http://dotfiles.com"><citetitle>
http://dotfiles.com</citetitle></ulink>. Just what it says - a collection
of configuration files.
</para>
</sect1>
<!-- the end -->
<sect1 id="The-End">
<title>The End </title>
<sect2>
<title>Copyright</title>
<para>
Copyright (c) by Guido Gonzato, <filename>ggonza at tin.it</filename>.
This document may be distributed only subject to the terms and conditions
set forth in the LDP License at <ulink
URL="http://www.linuxdoc.org/COPYRIGHT.html"><citetitle>
http://www.linuxdoc.org/COPYRIGHT.html</citetitle></ulink>, except that
this document must not be distributed in modified form without the
author's consent.
</para>
<para>
If you have questions, please refer to the Linux Documentation Project
home page, <ulink URL="http://www.linuxdoc.org"><citetitle>
http://www.linuxdoc.org</citetitle></ulink>.
</para>
</sect2>
<sect2>
<title>Feedback</title>
<para>
Perhaps even more than other HOWTOs, this one needs and welcomes your
suggestions, criticisms, and contributions. Not only is feedback welcome:
it's necessary. If you think something is missing or wrong, please email
me. If you have a distribution other than Red Hat/Mandrake and your config
files are different or placed in other directories, please tell me and
I'll include your tips. My aim is making life with Linux as easy as
possible.
</para>
<para>
Linux has a huge number of packages, so it's impossible to include
directions for all of them. Please keep your requests/suggestions
pertinent to the ``most reasonable'' programs---I'll leave it to your
common sense.
</para>
</sect2>
<sect2>
<title>Disclaimer</title>
<para>
This document is provided ``as is''. I put great effort into writing it as
accurately as I could, but you use the information contained in it at your
own risk. In no event shall I be liable for any damages resulting from the
use of this work.
</para>
<para>
Many thanks to all other HOWTO authors and man pages writers/maintainers,
whose work I've shamelessly pilfered; and to all people who provided me
with feedback.
</para>
<para>
I hope you'll find this work useful, though. Whenever I install a new
Linux box, I actually do...
</para>
<para>
Enjoy,
</para>
<para>
Guido <filename>=8-)</filename>
</para>
</sect2>
</sect1>
</article>