Next Previous Contents

3. Software Configuration

These are the the configuration files we are going to custimise: /etc/profile /etc/bashrc .bashrc .bashrc .bash_profile .bash_logout .inputrc .less .lessrc .xinitrc .fvwmrc .fvwm2rc95 .Xmodmap .Xmodmap.num .Xdefaults .jedrc .abbrevs.sl .joerc .emacs . Don't add users until you have completed your system configuration; you'll put the dot files in /etc/skel.

3.1 bash(1)

Arguably, the most important piece of software after the kernel. To tailor bash's behaviour, these are the main files to edit:

Examples of these files are shown below. First, the most important: /etc/profile. 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!


# /etc/profile

# System wide environment and startup programs
# Functions and aliases go in /etc/bashrc

# This file sets up the following features and programs:
#
#   o path
#   o prompts
#   o a few environment variables
#   o colour ls
#   o less
#   o rxvt
#
# Users can override these settings and/or add others in their
# $HOME/.bash_profile

# set a decent path (including Kde)
PATH="$PATH:/usr/X11R6/bin:/opt/kde/bin:$HOME/bin:."

# notify the user: login or non-login shell. If login, the prompt is
# coloured in blue; otherwise in 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"
fi

ESC="\033"
STYLE=';1m' # bold; choose which one to use
# STYLE='m' # plain
PS1="\[$ESC[$COLOUR;37$STYLE\]$USER:\[$ESC[37;40$STYLE\]\w\\$ "
PS2="> "

# no core dumps, please
ulimit -c 0

# set umask
if [ `id -gn` = `id -un` -a `id -u` -gt 14 ]; then
  umask 002
else
  umask 022
fi

# a few variables
USER=`id -un`
LOGNAME=$USER
MAIL="/var/spool/mail/$USER"
NNTPSERVER=news.iol.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
export LESS LESSEDIT LESSOPEN VISUAL LESSCHARDEF

# fix the backspace key in rxvt
if [ "$COLORTERM" != "" ] ; then
  stty erase ^H  # alternative: ^H
fi
      
for i in /etc/profile.d/*.sh ; do
  if [ -x $i ]; then
    . $i
  fi
done

# call fortune, if available
if [ -x /usr/games/fortune ] ; then
  echo ; /usr/games/fortune ; echo
fi

This is a sample /etc/bashrc:


# /etc/bashrc

# System wide functions and aliases
# Environment stuff goes in /etc/profile

# For some unknown reason bash refuses to inherit
# PS1 in some circumstances that I can't figure out.
# Putting PS1 here ensures that it gets loaded every time.

USER=`whoami`
if [ $LOGNAME = $USER ] ; then
  COLOUR=44  # blue
else
  COLOUR=45  # magenta
fi

if [ $USER = 'root' ] ; then
  COLOUR=41  # red
fi

ESC="\033"
STYLE=';1m'  # bold
# STYLE='m'    # plain
export PS1="\[$ESC[$COLOUR;37$STYLE\]$USER:\[$ESC[37;40$STYLE\]\w\\$ "
export PS2="> "
export CDPATH="$CDPATH:~"

alias which="type -path"
alias ls="ls $LS_OPTIONS"

This is a sample .bashrc:


# $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

# aliases
alias cp='cp -i'
alias l=less
alias lyx='lyx -width 900 -height 700'
alias mv='mv -i'
alias rm='rm -i'
alias x=startx

# A few useful functions

inst() # Install a .tar.gz archive in the current directory.
{ tar -zxvf $1 }

cz() # List the contents of a .zip archive.
{ unzip -l $* }

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.
{
  name=$1 ; tar -cvf $1 ; shift
  tar -rf ${name} $*
  gzip -S .tgz ${name}
}

This is a sample .bash_profile:


# $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"

This is a sample .inputrc:


# $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

To make the backspace and delete keys work correctly in xterm and other X11 applications, the following is also needed:

rxvt is a wee bit more complicated, as some compile--time options influence its behaviour. See the above /etc/profile.

More info in bash(1) and readline(3) man pages.

Don't expect every application to work correctly! If you run joe in xterm, for instance, some keys won't work; the same holds for versions of rxvt older than 2.4.5.

3.2 ls(1)

ls can display directory listings using colours to highlight different file types. To enable this feature, you just need a couple of lines in /etc/profile as seen above. However, this won't work with rxvt older than v. 2.21; use some flavour of xterm instead. It looks like rxvt has a bug that prevents it from inheriting the environment correctly in some circumstances. rxvt 2.4.5 upwards is OK.

Caldera's ls doesn't have colours, but there's an equivalent color-ls. Add this in /etc/bashrc:

alias ls="color-ls $LS_OPTIONS"

3.3 less(1)

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:

3.4 emacs(1)

I rarely use emacs, so I have only a couple of tips for you. Some emacs distributions don't come preconfigured for colours and syntax highlighting. Put this in your .emacs:

(global-font-lock-mode t)
(setq font-lock-maximum-decoration t)

This only works in X11. Moreover, to enable accented characters you'll add this line:

(standard-display-european 1)

I'll leave it to you to peruse all of emacs' documentation to find out how to tailor it to your needs---potentially, it can take months of hacking. The Dotfile generator (Section Configuration Software) is a good helping hand.

3.5 joe(1)

Some versions of joe don't work with colours in console, and some special keys don't work either. To my knowledge, no one has found a solution to these small nags. A quick and dirty (and inelegant) solution to the former problem is this:

~$ export TERM=vt100
~$ joe myfile
   (edit your file)
~$ export TERM=linux

Configure joe editing .joerc, .jstarrc or your favourite emulation; you can start from the system-wide config files in /usr/lib/joe.

3.6 jed(1)

This is my favourite editor: it does what I need, it's lighter and easier to configure than emacs, and emulates other editors quite well. Many users at my university use jed to emulate EDT, VMS' system editor.

jed's configuration files are .jedrc and /usr/lib/jed/lib/*; the former can be adapted from jed.rc in the latter directory.

3.7 efax(1)

This package is probably the most convenient for simple sending/receiving of faxes. You'll have to tailor the script /usr/bin/fax; easy job, but a couple of quirks caused me quite an headache:

3.8 TeX and Friends

I'll assume you have the teTeX distribution. Just a couple of things here:

3.9 Avoid PPProblems!

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 pppd package correctly installed and, if you will, suid root. Obviously, your ISP must support PPP.

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:

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.

You'll be surely better off if get hold of one of the following nice tools:

A Quick Start with eznet

First of all, create an /etc/resolv.conf like this:

nameserver w.x.y.z

where you'll insert the address of your ISP's nameserver. To create an account with eznet, issue the following command:

#~ eznet add service=YOUR_ISP user=NAME password=PASSWORD phone=PHONE

then try to dial your ISP with eznet up YOUR_ISP. If the modem waits for the dial tone and won't connect, then try this command:

#~ eznet change YOUR_ISP init0=atx3

To hang up, the command is eznet down. That's all!

3.10 POP Client

To retrieve your mail from a POP server, you use a POP client like fetchpop or fetchmail. The latter is more advanced, and is probably the only option if your ISP's PPP server can't deal with the command LAST. They're available on ftp://sunsite.unc.edu/pub/Linux/system/mail/pop.

To configure these clients:

3.11 X Window System (XFree86)

Setting Up the X Server

Come on, it's not difficult as it used to be... All major distributions include a tool for setting up X11 (e.g. XConfigurator, sax, XF86Setup, or at least xf86config). X configuration is virtually automatic these days, but a few video cards may refuse to work. Each time I experience problems setting up X on a system, I resort to a simple method that has always worked:

This has always worked for me, but your mileage may vary. Please note that most times X11 won't configure because the specs you choose for your monitor are too low! Start with conservative settings, i.e. 800x600 and 256 colours, then pump it up. Warning: these operations are dangerous and your monitor might be damaged!

Keypad

We have seen above how to make a few special keys work. The sample file .Xmodmap 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 .Xmodmap.num:

! Definitions can be found in <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

Make sure that your /etc/X11/XF86Config does not contain these three lines:

  ServerNumLock
  Xleds
  XkbDisable

and in case, comment them out. To re-enable the keypad, you'll issue the command xmodmap .Xmodmap.num.

Graphical Login with xdm

To be greeted by a graphical login, edit the file /etc/inittab, which should include a line like this:

x:5:respawn:/usr/bin/X11/xdm -nodaemon

where 5 is the runlevel corresponding to X11 (S.u.S.E. uses 4). Modify the line that defines the default runlevel (usually 2 or 3), changing it as above:

id:5:initdefault:

The number of colours is specified in /etc/X11/xdm/Xserver (AT2YD):

:0 local /usr/X11R6/bin/X -bpp 16  # 65k colours

If you already have .xinitrc, copy it to .xsession and make the latter executable with chmod +x .xsession. Now issue the command telinit 5 and you're in business.

Window Manager

Once you've managed to make X work, 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.

Some examples:

In short: if you don't mind editing config file, choose something like icewm, fvwm*, blackbox etc; if you do mind, the choice is currently restricted to KDE and WindowMaker.

It's important to have a good .xinitrc. An example:

#!/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 &

if [ "$1" = "" ] ; then  # default
  WINMGR=wmaker
else
  WINMGR=$1
fi

$WINMGR

Although it doesn't appear to be strictly required, make it executable with chmod +x .xinitrc.

This .xinitrc lets you choose the window manager: try

$ startx startkde # or other w.m.

(it doesn't work with some S.u.S.E. versions, though).

3.12 Users' Configurations

When you're done editing the dot files, copy them to /etc/skel as seen in Section Software Configuration. Note that .pinerc can't be fully tailored; make sure that at least the fields user-domain, smtp-server, and nntp-server are properly set up.

3.13 Upgrading

If you upgrade your machine, do your backup as usual and remember to save a few additional files. Some could be /etc/X11/XF86Config, /usr/bin/fax, all the stuff in /usr/local, the kernel configuration, the whole /etc, and all the mail in /var/spool/mail.


Next Previous Contents